From a24b4b2086afe4394ec52f5db633f3cc196ad8bf Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 25 May 2016 16:47:50 +0200 Subject: [PATCH] test --- examples/high.spl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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); } -- 2.20.1