
On Fri, Feb 6, 2009 at 8:47 AM, Christian Maeder
I wrote:
Magnus Therning wrote:
isSection line = not . isSpace . head $ line
I'ld be more careful with "head"! Imagine your binary fails with:
Prelude.head: empty list
see also http://haskell.org/haskellwiki/Haskell_programming_tips#Partial_functions_li...
countDays [] = [] countDays ls = let day = head ls count = length $ takeWhile (isSpace . head) $ tail ls in (day, count) : countDays (drop (1 + count) ls)
here too, and better use a pattern like: ls@(hd, tl)
oops, the pattern should be: ls@(hd : tl)
Another course of action would be to add exception handling; if head throws an exception then the input file isn't following the accepted syntax. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe