JohnBugner/elm-loop/2.1.0

Loop

Repeatedly apply a function to a value.

Looping

for : Int -> (a -> a) -> a -> a

Repeatedly apply a function to a value n times.

Loop.for 3 ((+) 5) 2 == 17
while : (a -> Bool) -> (a -> a) -> a -> a

Repeatedly apply a function to a value while the value satisfies the test.

Loop.while (\ n -> n < 15) ((+) 5) 2 == 17
whileJust : (a -> Maybe a) -> a -> a

Repeatedly apply a function to a value while the function returns 'Just'.

f : Int -> Maybe Int
f n =
    if n < 15
    then Just (n + 5)
    else Nothing


Loop.whileJust f 2 == 17