Advertisement
gatoatigrado3

haskell Data.Vector version of stackoverflow problem

Apr 9th, 2012
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. -- from http://stackoverflow.com/questions/10080273/how-to-get-good-performance-when-writing-a-list-of-integers-from-1-to-10-million
  2.  
  3. import Data.Monoid
  4. import Data.Text.Lazy.IO as Text
  5. import Data.Text.Lazy.Builder as Text
  6. import Data.Text.Lazy.Builder.Int as Text
  7. import Data.Vector as V
  8.  
  9. decimals = V.generate 10000000 (\i -> Text.decimal $ i + 1)
  10. with_newlines = V.map (`mappend` Text.singleton '\n') decimals
  11. concatd = V.foldr1 mappend with_newlines
  12. main = Text.putStrLn . Text.toLazyText $ concatd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement