<div dir="ltr"><div><div><div>\k -> k (x + y)<br><br></div>is equivalent to<br></div><br>blah k = k (x + y)<br><br></div>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.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 9:57 AM, Shishir Srivastava <span dir="ltr"><<a href="mailto:shishir.srivastava@gmail.com" target="_blank">shishir.srivastava@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi, </div><div><br></div><div>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</div><div><br></div><div>---------------</div><div><font face="monospace, monospace">Prelude> let add_cps x y = \k -> k (x+y)</font><br></div><div><div><font face="monospace, monospace">Prelude> add_cps 3 4 $ print </font></div><div><font face="monospace, monospace">7</font></div></div><div>---------------<br></div><div><br></div><div>I have some questions as to </div><div>1) what is the role of variable 'k' and what eventually happens to it.</div><div>2) How does print work after the $ because there is clearly no parameter being passed to it.</div><div><br></div><div>Thanks,</div><div><div><div dir="ltr"><font color="#0b5394"><font style="background-color:rgb(255,255,255)"><font face="georgia, serif" size="2">Shishir Srivastava</font><br></font></font><br></div></div></div>
</div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>