From db3fecf46f602320b48e7ce82ee770a46bba7ba6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 26 Dec 2014 14:20:19 -0400 Subject: Pattern-matching has been enriched with sub-structural matching. --- test2.lang | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'test2.lang') diff --git a/test2.lang b/test2.lang index cbce36ce8..55d7a14af 100644 --- a/test2.lang +++ b/test2.lang @@ -1,5 +1,5 @@ (import java.lang.System) -## (require "./another" as another) +(require "./another" as another) (definterface Function (: apply (-> [java.lang.Object] java.lang.Object))) @@ -18,11 +18,19 @@ (#Cons x xs*) (#Cons x (++ xs* ys)))) )# +#( (def (main args) + (if true + (case (#Pair "Pattern" "Matching") + (#Pair first second) + (do (:: (:: System out) (println first)) + (:: (:: System out) (println second)))) + (:: (:: System out) (println "FALSE")))) )# + (def (main args) (if true - (let variant (#Pair "Pattern" "Matching") - (case variant - (#Pair first second) + (let xs+ys (#Cons "Pattern" (#Cons "Matching" #Nil)) + (case xs+ys + (#Cons first (#Cons second #Nil)) (do (:: (:: System out) (println first)) (:: (:: System out) (println second))))) (:: (:: System out) (println "FALSE")))) -- cgit v1.2.3