99 Elm Problems/Problem 4/Solutions
Appearance
Solution 1: Recursive version
myLength list =
case list of
[] -> 0
head :: tail -> 1 + myLength tail
Solution 2: Using List.foldl
myLength = List.foldl (\_ b -> b + 1) 0
Solution 1: Recursive version
myLength list =
case list of
[] -> 0
head :: tail -> 1 + myLength tail
Solution 2: Using List.foldl
myLength = List.foldl (\_ b -> b + 1) 0