diff --git a/aufgaben/src/Test03/ListStuff.elm b/aufgaben/src/Test03/ListStuff.elm new file mode 100644 index 0000000..26d8fe0 --- /dev/null +++ b/aufgaben/src/Test03/ListStuff.elm @@ -0,0 +1,28 @@ +module Test03.ListStuff exposing (..) + +import Html + +contains : List comparable -> comparable -> Bool +contains list element = + case list of + head :: tail -> if head == element then True else contains tail element + [] -> False + + +length : List x -> Int +length x = + case x of + [] -> 0 + head :: tail -> 1 + length tail + + +length1 : List x -> Int -> Int +length1 x i = + case x of + [] -> i + head :: tail -> length1 tail (i + 1) + +l = List.range 1 10000000 + +main = Html.text (Debug.toString (length1 l 0)) +--main = Html.text (Debug.toString (contains l 23))