mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Added tutorial
This commit is contained in:
parent
b7271d167a
commit
b0e5bc26e3
10 changed files with 153 additions and 6 deletions
7
tutorial/Functions.lama
Normal file
7
tutorial/Functions.lama
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue