From dac675a417b33e7fbda512e5598139e58dfc1293 Mon Sep 17 00:00:00 2001 From: Martin Fredin Date: Tue, 16 May 2023 10:58:29 +0200 Subject: [PATCH] Add example --- sample-programs/working/presentation.crf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sample-programs/working/presentation.crf diff --git a/sample-programs/working/presentation.crf b/sample-programs/working/presentation.crf new file mode 100644 index 0000000..53a95d3 --- /dev/null +++ b/sample-programs/working/presentation.crf @@ -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)))) + + + +