{"action":"created","issue":{"url":"https://api.github.com/repos/vim-jp/vital.vim/issues/348","labels_url":"https://api.github.com/repos/vim-jp/vital.vim/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/vim-jp/vital.vim/issues/348/comments","events_url":"https://api.github.com/repos/vim-jp/vital.vim/issues/348/events","html_url":"https://github.com/vim-jp/vital.vim/pull/348","id":120794745,"number":348,"title":"Data.Counter: Implement \"Data.Counter\"","user":{"login":"haya14busa","id":3797062,"avatar_url":"https://avatars.githubusercontent.com/u/3797062?v=3","gravatar_id":"","url":"https://api.github.com/users/haya14busa","html_url":"https://github.com/haya14busa","followers_url":"https://api.github.com/users/haya14busa/followers","following_url":"https://api.github.com/users/haya14busa/following{/other_user}","gists_url":"https://api.github.com/users/haya14busa/gists{/gist_id}","starred_url":"https://api.github.com/users/haya14busa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haya14busa/subscriptions","organizations_url":"https://api.github.com/users/haya14busa/orgs","repos_url":"https://api.github.com/users/haya14busa/repos","events_url":"https://api.github.com/users/haya14busa/events{/privacy}","received_events_url":"https://api.github.com/users/haya14busa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-07T15:13:01Z","updated_at":"2015-12-09T08:46:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/vim-jp/vital.vim/pulls/348","html_url":"https://github.com/vim-jp/vital.vim/pull/348","diff_url":"https://github.com/vim-jp/vital.vim/pull/348.diff","patch_url":"https://github.com/vim-jp/vital.vim/pull/348.patch"},"body":"Data.Counter is similar to python's collections.Counter\r\n- https://docs.python.org/3.5/library/collections.html#collections.Counter\r\n- https://github.com/python/cpython/blob/a49faa270dbdc0ce4cb8b79d98915434e019533a/Lib/collections/__init__.py#L446-L448\r\n\r\nI'll add document later but the implementation is done and I assume you can understand most of behavior from comments, tests and python's documentation of collections.Counter.\r\nPlease take a look when you have time."},"comment":{"url":"https://api.github.com/repos/vim-jp/vital.vim/issues/comments/163152241","html_url":"https://github.com/vim-jp/vital.vim/pull/348#issuecomment-163152241","issue_url":"https://api.github.com/repos/vim-jp/vital.vim/issues/348","id":163152241,"user":{"login":"haya14busa","id":3797062,"avatar_url":"https://avatars.githubusercontent.com/u/3797062?v=3","gravatar_id":"","url":"https://api.github.com/users/haya14busa","html_url":"https://github.com/haya14busa","followers_url":"https://api.github.com/users/haya14busa/followers","following_url":"https://api.github.com/users/haya14busa/following{/other_user}","gists_url":"https://api.github.com/users/haya14busa/gists{/gist_id}","starred_url":"https://api.github.com/users/haya14busa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haya14busa/subscriptions","organizations_url":"https://api.github.com/users/haya14busa/orgs","repos_url":"https://api.github.com/users/haya14busa/repos","events_url":"https://api.github.com/users/haya14busa/events{/privacy}","received_events_url":"https://api.github.com/users/haya14busa/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T08:46:35Z","updated_at":"2015-12-09T08:46:35Z","body":"### 正直微妙なところ\r\npythonのcollections.Counterの`+`や`-`はnegative valueを無視します．\r\n現状のPRのVim script 実装では`+`, `-`に対応するメソッドは実装せず,\r\nnegative valueを無視しない`.update()`, `.subtract()` を実装しています．\r\n\r\nこれは返ってきたCounterにたいしてpythonでは`+c`, このVim\r\nscript版では`.keep_positive()`すれば十分じゃないか?というのと，\r\n`-`を実装しようとすると`subtract`(sub)はすでにあって使えないので名前がムズイ...という理由です．\r\n`+`は`.add()`でokなんですが...\r\n\r\n`.update()`の仕様はpythonの仕様と同じになってるけど`.add()`のほうがわかりやすそう.\r\nしかし`.add()`だとpythonにならってnegativeを無視したほうがいいのでは...?となるので実装してない．\r\n"}}