\k -> k (x + y)

is equivalent to

blah k = k (x + y)

Except for the fact that you have no function name to work with, which is why it is called an anonymous function (or lambda).  You can use it anywhere in your code without having to bother create a named function.

On Thu, May 28, 2015 at 9:57 AM, Shishir Srivastava <shishir.srivastava@gmail.com> wrote:
Hi, 

Reading on continuation I've came across this new style of creating the functions which I guess is not very clear in how it works

---------------
Prelude> let add_cps x y = \k -> k (x+y)
Prelude> add_cps 3 4 $ print 
7
---------------

I have some questions as to 
1) what is the role of variable 'k' and what eventually happens to it.
2) How does print work after the $ because there is clearly no parameter being passed to it.

Thanks,
Shishir Srivastava


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners