From 4e4a3d397f021ccfed0008878f8f6eb9a3da035e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 12 Mar 2015 10:47:49 +0100 Subject: [PATCH] Only takewhile to be done --- week5/camil/Origami.icl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 week5/camil/Origami.icl diff --git a/week5/camil/Origami.icl b/week5/camil/Origami.icl new file mode 100644 index 0000000..abd3cae --- /dev/null +++ b/week5/camil/Origami.icl @@ -0,0 +1,21 @@ +module Origami + +import StdEnv + +Start = and + [ sum` [1 .. 5] == sum [1 .. 5] + , prod` [1 .. 5] == prod [1 .. 5] + , flatten` [[],[1],[1,2],[1,2,3]] == flatten [[],[1],[1,2],[1,2,3]] + , reverse` [1 .. 5] == reverse [1 .. 5] + , takeWhile` ((<>) 0) [1,2,3,0,4,5,6] == takeWhile ((<>) 0) [1,2,3,0,4,5,6] + , maxList` [1 .. 5] == maxList [1 .. 5] + ] + +sum` = foldr (+) 0 +prod` = foldr (*) 1 +flatten` = foldr (++) [] +length` = foldl (\l e = l + 1) 0 +reverse` = foldl (\xs x = [x:xs]) [] +takeWhile` = takeWhile +maxList` [] = undef +maxList` [x:xs] = foldr max x xs -- 2.20.1