Skip to content

Instantly share code, notes, and snippets.

@satendrakumar
Last active March 26, 2017 08:20
Show Gist options
  • Save satendrakumar/53c66536ce9a25d883886e1102b789d5 to your computer and use it in GitHub Desktop.
Save satendrakumar/53c66536ce9a25d883886e1102b789d5 to your computer and use it in GitHub Desktop.
Prelude> let forall :: (a -> Bool) -> [a] -> Bool ; forall f []= True; forall f (x:xs) = f x && forall f xs
Prelude> forall even [2,4,6]
True
Prelude> forall even [2,4,5]
False
Prelude> let forall :: (a -> Bool) -> [a] -> Bool ; forall f []= True; forall f (x:xs) = if (f x) then forall f xs else False
Prelude> forall even [2,4,5]
False
Prelude> forall even [2,4,6]
True
Prelude> let forall :: (a -> Bool) -> [a] -> Bool ;forall f xs = and[f x| x<-xs ] // easy but not effective.
Prelude> forall even [2,4,5]
False
Prelude> forall even [2,4,6]
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment