Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created August 24, 2011 13:13
Show Gist options
  • Select an option

  • Save frenchy64/1168027 to your computer and use it in GitHub Desktop.

Select an option

Save frenchy64/1168027 to your computer and use it in GitHub Desktop.
Clojure
match.core.debug=> (let [x [1 2]]
(m-to-clj [x] [([1 2] | [3 4] | [5 6] | [7 8] | [9 10])] nil))
(binding [*rt-branches* (atom 0) *rt-breadcrumbs* (atom [])]
(cond
(if (or (seq? x) (sequential? x))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(or (seq? x) (sequential? x))))
true)
false) (let [x-head-19675 (first x)]
(cond
(if (= x-head-19675 1)
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(= x-head-19675 1)))
true)
false) (let [x-tail-19676 (rest x)]
(cond
(if (or
(seq? x-tail-19676)
(sequential? x-tail-19676))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(or
(seq? x-tail-19676)
(sequential? x-tail-19676))))
true)
false) (let
[x-head-19677
(first x-tail-19676)]
(cond
(if
(= x-head-19677 2)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(=
x-head-19677
2)))
true)
false)
(let
[x-tail-19678
(rest x-tail-19676)]
(cond
(if
(empty? x-tail-19678)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(empty?
x-tail-19678)))
true)
false)
nil
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
(if (= x-head-19675 3)
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(= x-head-19675 3)))
true)
false) (let [x-tail-19676 (rest x)]
(cond
(if (or
(seq? x-tail-19676)
(sequential? x-tail-19676))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(or
(seq? x-tail-19676)
(sequential? x-tail-19676))))
true)
false) (let
[x-head-19679
(first x-tail-19676)]
(cond
(if
(= x-head-19679 4)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(=
x-head-19679
4)))
true)
false)
(let
[x-tail-19680
(rest x-tail-19676)]
(cond
(if
(empty? x-tail-19680)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(empty?
x-tail-19680)))
true)
false)
nil
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
(if (= x-head-19675 5)
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(= x-head-19675 5)))
true)
false) (let [x-tail-19676 (rest x)]
(cond
(if (or
(seq? x-tail-19676)
(sequential? x-tail-19676))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(or
(seq? x-tail-19676)
(sequential? x-tail-19676))))
true)
false) (let
[x-head-19681
(first x-tail-19676)]
(cond
(if
(= x-head-19681 6)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(=
x-head-19681
6)))
true)
false)
(let
[x-tail-19682
(rest x-tail-19676)]
(cond
(if
(empty? x-tail-19682)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(empty?
x-tail-19682)))
true)
false)
nil
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
(if (= x-head-19675 7)
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(= x-head-19675 7)))
true)
false) (let [x-tail-19676 (rest x)]
(cond
(if (or
(seq? x-tail-19676)
(sequential? x-tail-19676))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(or
(seq? x-tail-19676)
(sequential? x-tail-19676))))
true)
false) (let
[x-head-19683
(first x-tail-19676)]
(cond
(if
(= x-head-19683 8)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(=
x-head-19683
8)))
true)
false)
(let
[x-tail-19684
(rest x-tail-19676)]
(cond
(if
(empty? x-tail-19684)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(empty?
x-tail-19684)))
true)
false)
nil
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
(if (= x-head-19675 9)
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj % '(= x-head-19675 9)))
true)
false) (let [x-tail-19676 (rest x)]
(cond
(if (or
(seq? x-tail-19676)
(sequential? x-tail-19676))
(do
(swap! *runtime-branches* inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(or
(seq? x-tail-19676)
(sequential? x-tail-19676))))
true)
false) (let
[x-head-19685
(first x-tail-19676)]
(cond
(if
(= x-head-19685 10)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(=
x-head-19685
10)))
true)
false)
(let
[x-tail-19686
(rest x-tail-19676)]
(cond
(if
(empty? x-tail-19686)
(do
(swap!
*runtime-branches*
inc)
(swap!
*runtime-breadcrumbs*
#(conj
%
'(empty?
x-tail-19686)))
true)
false)
nil
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else
(throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
:else (throw
(java.lang.Exception.
(str
"No match found. "
"Followed "
@*runtime-branches*
" branches."
" Breadcrumbs: "
@*runtime-breadcrumbs*)))))
nil
WARNING: match.core.debug, line 4: Non-exhaustive pattern matrix, consider adding :else clause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment