Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
foldr3 _ z [] k = k z
foldr3 f_cps z (x:xs ) k = f_cps x (foldr3 f_cps z xs k) $ \y -> k y
main = do print $ foldr3 (\x y k -> k $ x + y) 0 [1..3] id
print $ foldr3 (\x y k -> k $ x + y) 0 [1..3] (* 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment