42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
|
|
(with_import "./match.kp"
|
||
|
|
(do
|
||
|
|
(println "first "
|
||
|
|
(match 1
|
||
|
|
1 true
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
|
||
|
|
(println "second "
|
||
|
|
(match 3
|
||
|
|
1 true
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
(println "third "
|
||
|
|
(match "str"
|
||
|
|
1 true
|
||
|
|
"str" "It was a string!"
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
(println "fourth "
|
||
|
|
(match [ 1337 "str" ]
|
||
|
|
1 true
|
||
|
|
"str" "It was a string!"
|
||
|
|
[ 1337 "str" ] "matched an array of int str"
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
(println "fifth "
|
||
|
|
(match [ 1337 "str" 'sy ]
|
||
|
|
1 true
|
||
|
|
"str" "It was a string!"
|
||
|
|
[ 1337 "str" 'sy ] "matched an array of int str symbol"
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
(println "sixth "
|
||
|
|
(match [ 1337 "str" 'walla + 11 false 'kraken [ 'inner 'middle 'end ] [ 'inner1 'middle1 'end1 ] ]
|
||
|
|
1 true
|
||
|
|
"str" "It was a string!"
|
||
|
|
[ 1337 "str" 'walla + a false b [ 'inner c 'end ] d ] (str "matched, and got " a b c d)
|
||
|
|
a (+ a 1)
|
||
|
|
))
|
||
|
|
))
|