Add example
This commit is contained in:
parent
034f9d4faa
commit
dac675a417
1 changed files with 17 additions and 0 deletions
17
sample-programs/working/presentation.crf
Normal file
17
sample-programs/working/presentation.crf
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
data List a where
|
||||||
|
Nil : List a
|
||||||
|
Cons : a -> List a -> List a
|
||||||
|
|
||||||
|
foldr : (a -> b -> b) -> b -> List a -> b
|
||||||
|
foldr f y xs = case xs of
|
||||||
|
Nil => y
|
||||||
|
Cons x xs => f x (foldr f y xs)
|
||||||
|
|
||||||
|
sum xs = foldr (\x.\acc. x + acc) 0 xs
|
||||||
|
|
||||||
|
main = sum (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue