{"action":"created","issue":{"url":"https://api.github.com/repos/nathanmarz/specter/issues/34","labels_url":"https://api.github.com/repos/nathanmarz/specter/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/nathanmarz/specter/issues/34/comments","events_url":"https://api.github.com/repos/nathanmarz/specter/issues/34/events","html_url":"https://github.com/nathanmarz/specter/issues/34","id":114837826,"number":34,"title":"How do you compose select vectors?","user":{"login":"bsima","id":200617,"avatar_url":"https://avatars.githubusercontent.com/u/200617?v=3","gravatar_id":"","url":"https://api.github.com/users/bsima","html_url":"https://github.com/bsima","followers_url":"https://api.github.com/users/bsima/followers","following_url":"https://api.github.com/users/bsima/following{/other_user}","gists_url":"https://api.github.com/users/bsima/gists{/gist_id}","starred_url":"https://api.github.com/users/bsima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsima/subscriptions","organizations_url":"https://api.github.com/users/bsima/orgs","repos_url":"https://api.github.com/users/bsima/repos","events_url":"https://api.github.com/users/bsima/events{/privacy}","received_events_url":"https://api.github.com/users/bsima/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-03T15:11:34Z","updated_at":"2015-11-03T16:06:08Z","closed_at":"2015-11-03T15:59:52Z","body":"Hey @nathanmarz - really loving specter, and I'm trying to learn it to get the most power out of it. In particular, I'm wondering if you could help me understand this bit of code I wrote. This function walks into a Clojure map `m`, collects all of the keywords, then filters for a particular key `k`, and counts all instances of `k`:\r\n\r\n```clojure\r\n(defn cardinality [m k]\r\n  (first (select [(filterer (partial = k)) (view count)]\r\n                 (select (walker keyword?) m))))\r\n```\r\n\r\nThis works, but I have to call `first` and make two calls to `select`. When I try to compose the `select` vectors like this, I get back `IllegalArgumentException`:\r\n\r\n```clojure\r\n(defn cardinality-2 [m k]\r\n  (select [(walker keyword?)\r\n           (filterer (partial = k))\r\n           (view count)]\r\n          m))\r\n```\r\n\r\nUltimately, after experimentation, I refactored to:\r\n\r\n```clojure\r\n(defn cardinality-3 [m k] (count (select (walker (partial = k) m))))\r\n```\r\n\r\nBut I still don't understand why `cardinality-2` didn't work. I'm thinking that `walker` maybe doesn't compose like `filterer` and the other functions? The blog post and docs didn't really give me a good intuition about this in particular, so I was hoping you could help out when you have a chance."},"comment":{"url":"https://api.github.com/repos/nathanmarz/specter/issues/comments/153399450","html_url":"https://github.com/nathanmarz/specter/issues/34#issuecomment-153399450","issue_url":"https://api.github.com/repos/nathanmarz/specter/issues/34","id":153399450,"user":{"login":"bsima","id":200617,"avatar_url":"https://avatars.githubusercontent.com/u/200617?v=3","gravatar_id":"","url":"https://api.github.com/users/bsima","html_url":"https://github.com/bsima","followers_url":"https://api.github.com/users/bsima/followers","following_url":"https://api.github.com/users/bsima/following{/other_user}","gists_url":"https://api.github.com/users/bsima/gists{/gist_id}","starred_url":"https://api.github.com/users/bsima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsima/subscriptions","organizations_url":"https://api.github.com/users/bsima/orgs","repos_url":"https://api.github.com/users/bsima/repos","events_url":"https://api.github.com/users/bsima/events{/privacy}","received_events_url":"https://api.github.com/users/bsima/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T16:06:08Z","updated_at":"2015-11-03T16:06:08Z","body":"Ah, makes sense now, thanks!"}}