I have a case where I don't know how to apply laziness well.
Consider mutable containers (e.g. STArray or a database on disk).
How to iterate over them? I see the following possibilities:
* Give up laziness, provide only a conversion to the list of items.
Since the conversion is monadic, it
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