Created
September 23, 2019 08:31
-
-
Save chrisdone/0b6b68c92c164efd8f4ec2e6228d7cc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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