From: Mart Lubbers Date: Wed, 25 May 2016 14:47:50 +0000 (+0200) Subject: test X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=a24b4b2086afe4394ec52f5db633f3cc196ad8bf;p=cc1516.git test --- diff --git a/examples/high.spl b/examples/high.spl index 847e64b..226efa9 100644 --- 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); }