I have to find a function g : [Bool] -> Integer
such that g
gives lowest ubication where True
is in a list of booleans. For example,
g [False , False , False , False , True , False , True] ==> 5 g [False , True , True , False , False] ==> 2 g [] ==> ***Exception: empty list g [False , False] ==> ***Exception: There is no True in your list
I am not too interested in cases where the function takes []
or a list where there is no True
because I am working on a program where the boolean list is infinite and it's proved that there always exist True. I think a beginning of the definition of the following:
g :: [Bool] -> Integer g xs | xs == [] = error "empty list" | not (and xs) = error "There is no True in your list" | otherwise = ...
Can you help me to find ...
, please? Thank you very much.