Thanks to people who helped me with the task
Import two space separated columns of integers from file.
Claus Reinke <claus.reinke@talk21.com> recommends to exploit `lines'. Indeed, it bocomes shorter now: main = readFile "data" >>= (putStr . show . twoIntLists) where twoIntLists str = case span (not . null) $ dropWhile null $ lines str of (lns, lns') -> (readInts lns, readInts lns') readInts = map (\ str -> read str :: Integer) . dropWhile null Another question: has the Haskell Standard library a function for such a usable task as finding of occurence of a segment in a list? Say findSegmentBy (...) [2,2,3] [0,0,2,2,1,2,2,3,1,2,3] --> ([0,0,2,2,1], [2,2,3,1,2,3]) I have heard, an efficient algorithm (for large lists) for this is not so simple. ----------------- Serge Mechveliani mechvel@botik.ru
participants (1)
-
Serge D. Mechveliani