Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created September 23, 2019 08:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdone/0b6b68c92c164efd8f4ec2e6228d7cc4 to your computer and use it in GitHub Desktop.
Save chrisdone/0b6b68c92c164efd8f4ec2e6228d7cc4 to your computer and use it in GitHub Desktop.
{-# LANGUAGE BangPatterns #-}
import Control.DeepSeq
import Data.List hiding (foldl)
import Prelude hiding (foldl)
foldl = \f accumulator list ->
case list of
[] -> accumulator
x:xs -> foldlS f (f accumulator x) xs
foldlS = \f (!accumulator) list ->
case list of
[] -> accumulator
x:xs -> foldlS f (f accumulator x) xs
foldlS' = \f accumulator list ->
case force accumulator :: Int of
accumulator' -> case list of
[] -> accumulator'
x:xs -> foldlS f (f accumulator' x) xs
foldlS'' = \f accumulator list ->
case seq accumulator accumulator of
accumulator' -> case list of
[] -> accumulator'
x:xs -> foldlS f (f accumulator' x) xs
main = print "50000005000000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment