I've just started diving into core.match
(which is an awesome library, by the way), and I'd like to be able to extend match
to dispatch on arbitrary predicate functions. Unfortunately, it looks like that is not possible because the compiler cannot tell if a function is a function at macro-expansion time.
Is this correct, and if so (or if not), is there a way to hack it so that I can use a function, as demonstrated below, in a match
expression?
e.g.
(match [7]
[1] :a0
["green"] :a1
[prime?] :a2
[number?] :a3)
I'm aware of extending the interface via multimethods, and that worked quite nicely for using set literals for matching on containment within the set.
Thanks in advance.
It seems that you want to use the :guard
feature, http://github.com/clojure/core.match/wiki/Overview#guards