Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from swannodette/match.clj
Created June 20, 2013 19:55
Show Gist options
  • Save fogus/5826070 to your computer and use it in GitHub Desktop.
Save fogus/5826070 to your computer and use it in GitHub Desktop.
(let [x true
y true
z true]
(match [x y z]
[_ false true] 1
[false true _ ] 2
[_ _ false] 3
[_ _ true] 4
:else 5))
;; becomes >>
(try
(clojure.core/cond
(clojure.core/= y false) (try
(clojure.core/cond
(clojure.core/= z true) 1
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__1557__auto__
(if
(clojure.core/identical?
e__1557__auto__
clojure.core.match/backtrack)
(do
(throw
clojure.core.match/backtrack))
(throw e__1557__auto__))))
(clojure.core/= y true) (try
(clojure.core/cond
(clojure.core/= x false) 2
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__1557__auto__
(if
(clojure.core/identical?
e__1557__auto__
clojure.core.match/backtrack)
(do
(throw
clojure.core.match/backtrack))
(throw e__1557__auto__))))
:else (throw clojure.core.match/backtrack))
(catch
Exception
e__1557__auto__
(if (clojure.core/identical?
e__1557__auto__
clojure.core.match/backtrack)
(do
(try
(clojure.core/cond
(clojure.core/= z false) 3
(clojure.core/= z true) 4
:else (throw clojure.core.match/backtrack))
(catch
Exception
e__1557__auto__
(if (clojure.core/identical?
e__1557__auto__
clojure.core.match/backtrack)
(do 5)
(throw e__1557__auto__)))))
(throw e__1557__auto__))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment