
6 Feb
2009
6 Feb
'09
3:47 a.m.
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) Cheers again Christian