Answers for "haskell check if list is sorted"

0

haskell check if list is sorted

sorted :: (Ord a) => [a] -> Bool
sorted [] = True
sorted [x] = True
sorted (x:y:xs) = if x <= y then sorted (y:xs) else False
Posted by: Guest on January-29-2021

Browse Popular Code Answers by Language