Skip to content

Instantly share code, notes, and snippets.

@jb55
Last active August 18, 2017 18:04
Show Gist options
  • Save jb55/111a5a5057cb8ea550ca3327b311475b to your computer and use it in GitHub Desktop.
Save jb55/111a5a5057cb8ea550ca3327b311475b to your computer and use it in GitHub Desktop.
sequential :: [Int] -> Bool
sequential = all (==True) (zipWith beside xs (tail xs))
where
beside n1 n2 = abs (n2 - n1) == 1
{-
λ> sequential [1,2,3]
True
λ> sequential [3,2,1]
True
λ> sequential [3,1,2]
False
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment