Originally Posted by
MutantJohn
What are some of the super cool things that Haskell can do over a language like C++?
In my opinion, pattern matching and currying.
Examples:
Code:
(x, y) = (1, 2)
length [] = 0
length (_ : foo) = 1 + length foo
//Not limited to : , works for your own constructors too.
This is something I really want to be able to do in C++!
Code:
foo x y = x + y
foo x //gives you the equivalent of std::bind(foo, x, _1) in a cleaner way
(+42) //gives you a function that adds 42 to its single argument