Hi Mark,
isSorted xs = and (zipWith (=) xs (tail xs))
In other words: When is a list xs sorted? If each element in xs is
less than or equal to its successor in the list (i.e., the corresponding
element in tail xs).
That's right ... under cbn! At the same time David's version with
Hi David,
| Can anyone shed some light on the following error? Thanks in advance.
|
| isSorted :: Ord a = [a] - Bool
| isSorted [] = True
| isSorted [x] = True
| isSorted (x1:x2:xs)
| | x1 = x2 = isSorted (x2:xs)
| | otherwise = False
I'm branching away from your question, but