add examples

This commit is contained in:
crumbtoo
2023-12-14 13:29:08 -07:00
parent f2b6e43d59
commit 633882119b
3 changed files with 19 additions and 0 deletions

3
examples/constDivZero.hs Normal file
View File

@@ -0,0 +1,3 @@
k x y = x;
main = k 3 ((/#) 1 0);

7
examples/factorial.hs Normal file
View File

@@ -0,0 +1,7 @@
fac n = case (==#) n 0 of
{ 1 -> 1
; 0 -> (*#) n (fac ((-#) n 1))
};
main = fac 3;

9
examples/sumList.hs Normal file
View File

@@ -0,0 +1,9 @@
nil = Pack{0 0};
cons x y = Pack{1 2} x y;
list = cons 1 (cons 2 (cons 3 nil));
sum l = case l of
{ 0 -> 0
; 1 x xs -> (+#) x (sum xs)
};
main = sum list;