parent
7dc8a2f21e
commit
0c891ed95c
|
@ -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))
|
Loading…
Reference in New Issue