Last active
December 9, 2022 07:31
-
-
Save kaveet/b77f2f3add61d9c3afdb6852b7f36b03 to your computer and use it in GitHub Desktop.
Check if list is sorted in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sorted where | |
sorted :: (Ord a) => [a] -> Bool | |
sorted [] = True | |
sorted [x] = True | |
sorted (x:y:xs) = if x <= y then sorted (y:xs) else False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haskell is so cool!