Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-31 Thread Michael Gardner
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

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Ben Smith-Mannschott
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]

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Ben Smith-Mannschott
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

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Michael Gardner
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

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Aaron Cohen
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

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Moritz Ulrich
(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

Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Michael Gardner
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