On Feb 3, 6:41 pm, Tayssir John Gabbour <[email protected]>
wrote:
> ;; Works, but is ugly.
> (let [xset #{{:a 1, :b 1, :c 1}
> {:a 2, :b 2, :c 2}
> {:a 3, :b 3, :c 3}}]
> (project (select #(= (:a %) 1) xset)
> [:b :c]))
>
> So what I currently do is this:
>
> ;; Works, with a little blemish.
> (-> #{{:a 1, :b 1, :c 1}
> {:a 2, :b 2, :c 2}
> {:a 3, :b 3, :c 3}}
> ((revargs select) #(= (:a %) 1))
> (project [:b :c]))
>
> And I'm curious whether there's a better way.
Two, I won't say better - just different, ways:
(defn select*
[xset pred]
(select pred xset))
then use select* in place of select.
OR
(-> #{{:a 1, :b 1, :c 1}
{:a 2, :b 2, :c 2}
{:a 3, :b 3, :c 3}}
(->> (select #(= (:a %) 1)))
(project [:b :c]))
=> #{{:c 1, :b 1}}
Walt
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en