<br><div><span class="gmail_quote">On 10/1/07, <b class="gmail_sendername">PR Stanley</b> &lt;<a href="mailto:prstanley@ntlworld.com">prstanley@ntlworld.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>&gt; &gt; f x = x + x<br>&gt; &gt; Is the &quot;x&quot; use to create a pattern in the definition and when f is<br>&gt; &gt; called it&#39;s replaced by a value?<br>&gt;<br>&gt;Those equation-like definitions are syntactic sugar for lambda
<br>&gt;abstractions. f could as well be defined as f = \x -&gt; x + x.<br><br>Please elaborate</blockquote><div><br>First, the<br><br>f x = <br><br>part says that f is a function which takes a single parameter, called x.&nbsp; The other side of the = sign gives the function body: in this case, x + x.&nbsp; This is exactly the same thing that is expressed by the lambda expression
<br><br>\x -&gt; x + x<br><br>This expression defines a function that takes a single parameter called x, and returns the value of x + x.&nbsp; The only difference is that with the lambda expression, this function is not given a name.&nbsp; But you can easily give the function a name (just as you can give any Haskell expression a name) by writing
<br><br>f = \x -&gt; x + x<br><br>In general, writing<br><br>g x y z = blah blah<br><br>is just a shorthand for<br><br>g = \x -&gt; \y -&gt; \z -&gt; blah blah.<br><br>That is, it simultaneously creates a function expression, and assigns it a name.
<br><br>Does that help?<br>-Brent<br></div></div>