On Jul 31, 2012, at 12:00 AM, Ben Smith-Mannschott wrote:
> ((some-fn :k1 :k2) m)
Ah, excellent. Yet another hidden gem in clojure I'd somehow overlooked until
now!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email t
On Tue, Jul 31, 2012 at 7:00 AM, Ben Smith-Mannschott
wrote:
> On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen wrote:
>> On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich
>> wrote:
>>> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
>>
>> For even more fun, try (some m [:k1 :k2]
On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen wrote:
> On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich
> wrote:
>> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
>
> For even more fun, try (some m [:k1 :k2]) :)
The flip side of this proposal is:
((some-fn :k1 :k2) m)
Whic
On Jul 30, 2012, at 6:08 PM, Aaron Cohen wrote:
> For even more fun, try (some m [:k1 :k2]) :)
Wow, that's perfect. It even works with string keys! Thanks, guys.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to cl
On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich wrote:
> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
For even more fun, try (some m [:k1 :k2]) :)
--Aaron
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group
(some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
On Tue, Jul 31, 2012 at 12:48 AM, Michael Gardner wrote:
> Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m?
> Using a let can be awkward if the expression isn't already wrapped in one;
> '(apply #(or
Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m?
Using a let can be awkward if the expression isn't already wrapped in one;
'(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's
something clever I'm missing; any ideas?
--
You received this message