Hi,
Hat: The Haskell Tracer.
http://www.haskell.org/hat/
From the site:
Hat helps locating errors in programs. Furthermore, it is useful for
understanding how a (correct) program works, especially for teaching and
program maintenance. Hat is not a time or space profiler. Hat can be used
for
Using the same basic structure you did, and foldr, I think below is the
simplest method:
import Data.Maybe
searchList :: (a - Bool) - [a] - Maybe [a]
searchList p xs = foldr (\x acc - if p x then Just (x: fromMaybe [] acc)
else acc) Nothing xs
ghci
The following program should work:
===compress.hs=
toList :: (Eq a) = [a] - [[a]]
toList [] = []
toList x = start : toList end
where (start, end) = span (==(head x)) x
toTuple :: [a] - (a, Int)
toTuple x = (head x, length x)
compress :: Eq a = [a] - [(a, Int)]
compress x =