[ create a new paste ] login | about

Link: http://codepad.org/EX1ho669    [ raw code | output | fork ]

Haskell, pasted on Mar 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- | checkSort verify if a given list is sorted
-- Point-free version is hard to find BUT is redable.
-- Level: Medium
--
-- Examples:
--
-- >>> checkSort ([1..10] :: [Int])
-- True
--
-- >>> checkSort $ ([1,3,2] :: [Int])
-- False
--
-- >>> checkSort []
-- True
--
checkSort :: Ord a => [a] -> Bool
checkSort = (\x -> and $ zipWith (<) x (tail x))

main = print $ map checkSort [[1..10],[1,3,2],[]]


Output:
1
[True,False,True]


Create a new paste based on this one


Comments: