Added tutorial

This commit is contained in:
Dmitry Boulytchev 2020-02-19 15:28:29 +03:00
parent b7271d167a
commit b0e5bc26e3
10 changed files with 153 additions and 6 deletions

7
tutorial/Functions.lama Normal file
View file

@ -0,0 +1,7 @@
import Fun;
import List;
printf ("Functions are first-class, higher-order.\n");
printf ("Factorial: %d\n", fix (fun (f) {fun (n) {if n == 1 then 1 else n * f (n-1) fi}})(5));
printf ("Function composition: %d\n", foldl (infix #, id, map (fun (i) {fun (x) {x+i}}, {1, 2, 3})) $ 10)