aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorEduardo Julian2014-11-27 02:03:19 -0400
committerEduardo Julian2014-11-27 02:03:19 -0400
commit1a2b6841604558266f2cbf5bcf1373ea257183c9 (patch)
treeda5cbb9a4c330a6790a06f0e081784807a496381 /src/example
parenta96bb768a5f02c2dc9c0de1e50dc14376d2e7f35 (diff)
+ Added some very basic pattern-matching with destructuring.
Diffstat (limited to 'src/example')
-rw-r--r--src/example/test1.lang7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/example/test1.lang b/src/example/test1.lang
index da3d3fa87..43f3111fa 100644
--- a/src/example/test1.lang
+++ b/src/example/test1.lang
@@ -7,3 +7,10 @@
(#Cons [val (repeat (-' n 1) val)])))
(repeat 5 5)
+
+(def (fold f init inputs)
+ (case inputs
+ (#Nil []) init
+ (#Cons [head tail]) (fold f (f init head) tail)))
+
+(fold * 1 (repeat 5 5))