
21 Jul
2008
21 Jul
'08
3:25 a.m.
Felipe Lessa wrote:
Rafael Gustavo da Cunha Pereira Pinto wrote:
-------------sample.in------------- 01 02 03 04 05 06 10 11 15 18 29 45 19 22 10 01 23 14 -----------------------------------------
convert :: String -> [Int] convert = map read . words
read :: FilePath -> IO [[Int]] read fp = (map convert . lines) `fmap` readFile fp
Naming the new function read is a bad idea :)
Right now I am using hGetLine and getting a string. Is is possible to use read to convert this in a list of Num?
As Felipe demonstrates, putting the entire file into a String via readFile is often easier than reading it piecemeal with hGetLine . Regards, apfelmus