Hm, on my machine Don's code has exactly the same performance my code above.
Also, replacing the 'test' and 'parse' functions with this one add :: Int -> Int -> S.ByteString -> Int add k i s = fst $ S.foldl' f (i, 0) s where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) | otherwise = (i, 0) f (!i, !n) w = (i, 10*n+ord w-ord '0') increases performance by another 15% (0.675s vs 0.790s) 2009/9/1 Jason Dusek <jason.du...@gmail.com>: > I've updated Don Stewart's solution to compile with the modern > ByteString libs. I'll be looking at ways to improve the > performance of the `bytestring-nums` package. > > -- > Jason Dusek > > > http://github.com/jsnx/bytestring-nums/blob/d7de9db83e44ade9958fb3bfad0b29ede065b5dd/SPOJDons.hs > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe