Created
May 13, 2010 10:11
-
-
Save aboekhoff/399685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; using a pattern matching macro | |
(defn test [x] | |
(match x | |
(? (comp not number?)) :not-a-number | |
(? #(< % 42)) (recur (inc x)) | |
42 :booya! | |
_ :too-high!)) | |
;; running mexpand-all on the match clause produces this mess: | |
(let* | |
[t__3449__auto__ | |
(if ((comp not number?) x) :not-a-number :somnium.yap/match-failure)] | |
(if | |
(clojure.core/not | |
(clojure.core/= t__3449__auto__ :somnium.yap/match-failure)) | |
t__3449__auto__ | |
(let* | |
[t__3449__auto__ | |
(if | |
((fn* ([p1__5784#] (< p1__5784# 42))) x) | |
(recur (inc x)) | |
:somnium.yap/match-failure)] | |
(if | |
(clojure.core/not | |
(clojure.core/= t__3449__auto__ :somnium.yap/match-failure)) | |
t__3449__auto__ | |
(let* | |
[t__3449__auto__ | |
(if (clojure.core/= x 42) :booya! :somnium.yap/match-failure)] | |
(if | |
(clojure.core/not | |
(clojure.core/= t__3449__auto__ :somnium.yap/match-failure)) | |
t__3449__auto__ | |
(let* | |
[t__3449__auto__ :too-high!] | |
(if | |
(clojure.core/not | |
(clojure.core/= t__3449__auto__ :somnium.yap/match-failure)) | |
t__3449__auto__ | |
(somnium.yap/raise! | |
"no matching clause for: " | |
(clojure.core/pr-str x) | |
" among patterns:\n" | |
'(? (comp not number?)) | |
"\n" | |
'(? (fn* [p1__5784#] (< p1__5784# 42))) | |
"\n" | |
'42 | |
"\n" | |
'_))))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment