3 ms·
Nice feature of doing it like in the post: (filter (every-pred :admin? :mod?) people) is that a) this arguably conses less, by building only one results lis
by TeMPOraL 7y ago
Nice feature of doing it like in the post:
(filter (every-pred :admin? :mod?) people)
is that a) this arguably conses less, by building only one results list, and b) :admin? and :mod? are just regular arguments, which means they could be replaced by data. I'm thinking of:
(let [acl [:admin? :mod?]]
(filter (apply every-pred acl) people))
This capitalizes on Clojure's interesting design decision in which when funcalled, a :keyword resolves to function that gets an element with the name :keyword from the map passed as the argument.
- drcode 7y agoI admit a case can be made for having every-pred in the language, since from a mathematical standpoint predicate composition is an innate low-level feature (putting the questionable naming issue aside)
- int_19h 7y ago> this arguably conses less, by building only one results list Aren't lazy sequences idiomatic in Clojure?