Diff
Not logged in

Differences From Artifact [4438bc82733dcb16]:

To Artifact [fd8a6f88bc7a9f4a]:


6 6 7 7 let upto = fun(n, f){ 8 8 if n > 0: upto(n-1,f); 9 9 f(n) 10 10 }; 11 11 12 12 var compose = fun(f,g){ fun(x){f(g(x))} }; 13 -var "<<" = compose; 13 +var << = compose; 14 14 15 15 upto(18, print<<fib); 16 16 17 17 18 18 ###################################### 19 19 # Omake. Feel the automatic memoization! 20 20 21 21 # Set up a mirror layer (do-the-same-thing layer) of @value 22 22 @@m(x){x}; 23 -@m "+" (x,y) { @value(@m(x)+@m(y)) }; 24 -@m "-" (x,y) { @value(@m(x)-@m(y)) }; 25 -@m "<" (x,y) { @value(@m(x)<@m(y)) }; 26 -@m "if" (c,t,e) { @value(if @m(c) then @m(t()) else @m(e())) }; 23 +@m + (x,y) { @value(@m(x)+@m(y)) }; 24 +@m - (x,y) { @value(@m(x)-@m(y)) }; 25 +@m < (x,y) { @value(@m(x)<@m(y)) }; 26 +@m if (c,t,e) { @value(if @m(c) then @m(t()) else @m(e())) }; 27 27 28 28 # Helper function to call fib in layer @m 29 29 def fibm(x @value) { @m(fib(@value(x))) }; 30 30 31 31 # User defined layers are automatically memoized. 32 32 # So this is much faster. 33 33 upto(18, print<<fibm);