Skip to content

Instantly share code, notes, and snippets.

@qrilka
Created July 3, 2013 18:44
Show Gist options
  • Save qrilka/5921567 to your computer and use it in GitHub Desktop.
Save qrilka/5921567 to your computer and use it in GitHub Desktop.
Endo difflists
λ> import Data.Monoid
λ> let s = take 20000000 $ repeat 'a'
λ> :set +s
λ> length $ appEndo(Endo (s ++) `mappend` Endo (s ++) ) []
40000000
(0.86 secs, 2242175512 bytes)
λ> length $ appEndo(Endo (++ s) `mappend` Endo (++ s) ) []
40000000
(0.26 secs, 1121875736 bytes)
λ> length $ appEndo(Endo (++ s) `mappend` Endo (++ s)`mappend` Endo (++ s) ) []
60000000
(0.62 secs, 3362517000 bytes)
λ> length $ appEndo(Endo (s ++) `mappend` Endo (s ++) `mappend` Endo (s ++)) []
60000000
(1.53 secs, 3361937832 bytes)
λ> length $ s ++ s ++ s ++ []
60000000
(1.54 secs, 3361416360 bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment