Dear Cafe,Here's a basic exercise in list processing: define a functionthat breaks up its input list into a list of increasing "runs"; e.g.,runs :: Ord a => [a] -> [[a]]runs [3,4,5,6,2,3,4,1,2,1] ---> [[3,4,5,6],[2,3,4],[1,2],[1]]A natural solution is the following:My question: can we do better than this? It seems that this solution is constantly building and breaking apart pairs. (Or is it, when optimized?)runs [] = []
runs (x:xs) = let (ys, zs) = run x xsin (x:ys) : runs zswhere
run x [] = ([], [])
run x (y:ys) = if x <= ythen let (us, vs) = run y ysin (y:us, vs)else ([], y:ys)Todd Wilson