Following statement
returns True, if all the elements in the list are even, else False.
allEven list = (list == [x | x <- list, even x])
Prelude> let allEven list = (list == [x | x <- list, even x]) Prelude> Prelude> allEven [4, 5, 6] False Prelude> allEven [4, 8, 6] True Prelude> allEven [] True
No comments:
Post a Comment