Extra 2 Solution - takeWhile

takeWhile : (a -> Bool) -> (List a) -> (List a)
takeWhile predicate xs =
  case xs of
    [] -> 
        []

    hd::tl  -> 
        if (predicate hd) then
            hd :: takeWhile predicate tl
        else 
            []

Back to problem

results matching ""

    No results matching ""