lama_byterun/tutorial/Functions.lama
Dmitry Boulytchev b0e5bc26e3 Added tutorial
2020-02-19 15:28:29 +03:00

7 lines
283 B
Text

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)