You could do it with `condp`: (condp #(%1 %2) value foo-pred? (foo-result) bar-pred? (bar-result) else? (default-result))
-S On Saturday, April 20, 2013 5:15:14 AM UTC-4, Ken Scambler wrote: > > Hi there, > I'm getting started with Clojure, and found myself really missing > Scala-style pattern matching. Now I know about Matchure and core.match, > but all I really needed was a cond using test predicates rather than > boolean expressions, like this: > > (condval value > foo-pred? (foo-result) > bar-pred? (bar-result) > else? (default-result)) > > (Where 'else? is a predicate that ignores the argument and returns true) > > Lisp being Lisp, I rolled my own and it works fine. But I was wondering > if there was an idiomatic way to do this in the standard library, without > the repetition that cond necessitates when you are testing against a single > value. > > Cheers, > Ken > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.