SHARE
TWEET

foldl' strictness

a guest Jun 2nd, 2017 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ ghci
  2. GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
  3. Prelude> :m + Data.List
  4. Prelude Data.List> let f (acc, len) x = (acc + x, len + 1)
  5. Prelude Data.List> let f' (acc, len) x = let acc' = acc + x; len' = len + 1 in acc' `seq` len' `seq` (acc', len')
  6. Prelude Data.List> :set +s
  7. Prelude Data.List> foldl' f (0, 0) [1..1000000]
  8. (500000500000,1000000)
  9. (0.95 secs, 355,322,552 bytes)
  10. Prelude Data.List> foldl' f' (0, 0) [1..1000000]
  11. (500000500000,1000000)
  12. (0.32 secs, 184,080,976 bytes)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top