Skip to content

Instantly share code, notes, and snippets.

@folone
Created February 6, 2013 08:08
Show Gist options
  • Save folone/4721107 to your computer and use it in GitHub Desktop.
Save folone/4721107 to your computer and use it in GitHub Desktop.
% ghci
GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let n = map show [1..10]
Prelude> let c = \x y -> concat ["(", x, "+", y, ")"]
Prelude> foldl c "0" n
"((((((((((0+1)+2)+3)+4)+5)+6)+7)+8)+9)+10)"
Prelude> foldr c "0" n
"(1+(2+(3+(4+(5+(6+(7+(8+(9+(10+0))))))))))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment