Skip to content

Instantly share code, notes, and snippets.

@lenstr
Created April 29, 2012 09:51
Show Gist options
  • Save lenstr/2549100 to your computer and use it in GitHub Desktop.
Save lenstr/2549100 to your computer and use it in GitHub Desktop.
comp
-- LeNsTR
module Main where
comp :: (a -> a -> Bool) -> [a] -> Bool
comp f = comp' where
comp' (x:[]) = True
comp' (x:y:[]) = x `f` y
comp' (x:y:(h:t)) | x `f` y = comp' (y:h:t)
| otherwise = False
main = print $ map (comp (<)) [[1,2,3,4] -- True
,[1,2,4,3] -- False
,[1]] -- True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment