repositories
/
cc1516.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7ee2464
)
test
author
Mart Lubbers
<mart@martlubbers.net>
Wed, 25 May 2016 14:47:50 +0000
(16:47 +0200)
committer
Mart Lubbers
<mart@martlubbers.net>
Wed, 25 May 2016 14:47:50 +0000
(16:47 +0200)
examples/high.spl
patch
|
blob
|
history
diff --git
a/examples/high.spl
b/examples/high.spl
index
847e64b
..
226efa9
100644
(file)
--- a/
examples/high.spl
+++ b/
examples/high.spl
@@
-1,11
+1,19
@@
-plus(v, w, x, y, z) {
- return v + w + x + y + z;
+plus(x, y) {
+ return x + y;
+}
+
+fold(f, b, l) {
+ var x = l;
+ var acc = b;
+ while(!isEmpty(l)){
+ acc = f(acc, x.hd);
+ x = x.tl;
+ }
+ return acc;
}
main (){
- var a = 1 : 2 : 3 : 4 : 5 : [];
- var a = plus(1, 2);
- var b = a(3, 4);
- var c = b(5);
- print(c);
+ var a = 1 : 2 : [];
+ var b = fold(plus, 0, a);
+ print(b);
}