Reputation: 1582
What is a simpler way I can write this:
(map #(map first %) [[[1 2] [3 4]] [[5 6]]])
=> ((1 3) (5))
Usually there are simpler ways to do this. I'm just not sure what.
I'm looking for a point free solution. Specifically this part (map #(map first %) coll)
.
Upvotes: 0
Views: 85
Reputation: 45806
A point-free function expressing this would be:
(def firsts (partial map #(map first %)))
or to go fully point free:
(def firsts (partial map (partial map first)))
Used like:
(firsts [[[1 2] [3 4]] [[5 6]]])
Whether or not this is "simplified" though is subjective. I prefer the non-point-free version myself.
Upvotes: 2