diff options
author | Eduardo Julian | 2015-01-02 03:29:32 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-02 03:29:32 -0400 |
commit | 7ae54659d09aef5ced3544c650c80d7580a0dbb7 (patch) | |
tree | 562df421d70479622a01fb1915884b5f60a3a0aa /test2.lang | |
parent | f28db7decf3330379f3f4ab190a9bc01deb50b91 (diff) |
Fixed a bug in pattern-matching when expanding sequential tests.
Diffstat (limited to 'test2.lang')
-rw-r--r-- | test2.lang | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/test2.lang b/test2.lang index c697ae3c8..b3756a6e8 100644 --- a/test2.lang +++ b/test2.lang @@ -18,37 +18,36 @@ (#Cons x xs*) (#Cons x (++ xs* ys)))) -#( (def (template elems) - (case elems - #Nil - elems - - (#Cons head tail) - (case head - (#Cons (#Symbol "~") (#Cons unquoted #Nil)) - (#Cons unquoted (template tail)) +(def (template elems) + (case elems + #Nil + elems - (#Cons (#Symbol "~@") (#Cons spliced #Nil)) - (#Cons (#Symbol "++") (#Cons spliced (template tail))) + (#Cons head tail) + (case head + (#Cons (#Symbol "~") (#Cons unquoted #Nil)) + (#Cons unquoted (template tail)) - _ - (#Cons head (template tail))) - )) )# + (#Cons (#Symbol "~@") (#Cons spliced #Nil)) + (#Cons (#Symbol "++") (#Cons spliced (template tail))) -#( )# + _ + (#Cons head (template tail)) + ) + )) (def (main args) - (if true - (case (++ (#Cons "Pattern" #Nil) (#Cons "Matching" #Nil)) - (#Cons "Pattern" (#Cons second #Nil)) - (do (:: (:: System out) (println "Branch #1")) - (:: (:: System out) (println second))) - - (#Cons first (#Cons second #Nil)) - (do (:: (:: System out) (println "Branch #2")) - (:: (:: System out) (println first)) - (:: (:: System out) (println second)))) - (:: (:: System out) (println "FALSE")))) + (case (template (#Cons (#Cons (#Symbol "~@") (#Cons (#Symbol "Pattern") #Nil)) #Nil) + ## (#Cons (#Cons (#Symbol "~") (#Cons (#Symbol "Pattern") #Nil)) #Nil) + ) + (#Cons word #Nil) + (do (:: (:: System out) (println "Branch #1")) + (:: (:: System out) (println word))) + + (#Cons (#Symbol op) spliced) + (do (:: (:: System out) (println "Branch #2")) + (:: (:: System out) (println op))) + )) #( (defmacro (' form) (case form @@ -73,8 +72,20 @@ (def (main args) (if true (let f (lambda [x] (lambda [y] (x y))) - (let g (lambda [x] const) - (::+ System out (println (f g "WE'VE GOT CLOSURES!"))) - ## (:: (:: System out) (println (f g "WE'VE GOT CLOSURES!"))))) + (let g (lambda [x] x) + (::+ System out (println (f g "WE'VE GOT CLOSURES!"))))) + (:: (:: System out) (println "FALSE")))) + + (def (main args) + (if true + (case (++ (#Cons "Pattern" #Nil) (#Cons "Matching" #Nil)) + (#Cons "Pattern" (#Cons second #Nil)) + (do (:: (:: System out) (println "Branch #1")) + (:: (:: System out) (println second))) + + (#Cons first (#Cons second #Nil)) + (do (:: (:: System out) (println "Branch #2")) + (:: (:: System out) (println first)) + (:: (:: System out) (println second)))) (:: (:: System out) (println "FALSE")))) )# |