<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Functions in F#</title>
	<atom:link href="http://pradeepc.net/blog/2009/12/21/functions-in-f/feed/" rel="self" type="application/rss+xml" />
	<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/</link>
	<description>the colors of my life</description>
	<lastBuildDate>Thu, 02 Feb 2012 09:32:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: .entrypoint &#187; Blog Archive &#187; Functions in F# Part 2</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-6100</link>
		<dc:creator>.entrypoint &#187; Blog Archive &#187; Functions in F# Part 2</dc:creator>
		<pubDate>Fri, 12 Mar 2010 03:36:12 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-6100</guid>
		<description>[...] had written a post on Functions in F# a couple of days ago and Binil posted a comment which prompted me to post a follow up to add some [...]</description>
		<content:encoded><![CDATA[<p>[...] had written a post on Functions in F# a couple of days ago and Binil posted a comment which prompted me to post a follow up to add some [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pradeep</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-6002</link>
		<dc:creator>Pradeep</dc:creator>
		<pubDate>Wed, 23 Dec 2009 21:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-6002</guid>
		<description>I don&#039;t know the correct answer to this, but here is what I think it could be. 

In the expression (3 * x), 3 is an integer. For an integer type the * operator is defined only to work with ints. So unless we have specified x to be of another type (in which case the compiler will throw an error) the compiler assumes the type of x to be int. The return value of int * int is int.

Now let us consider the expression x * y, where no type information has been specified for x and y. The compiler would expect the type of x and y to be something that has the operator &#039;*&#039; defined for the type. If we haven&#039;t overloaded the * for any custom types, the compiler would have to select from a list of types for which * is predefined. Those would be the numerical types like int, float etc.
In the absense of any additional type information to chose between them, the compiler defaults to int.

I should clarify that this is my guess, not a documented fact :-)</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know the correct answer to this, but here is what I think it could be. </p>
<p>In the expression (3 * x), 3 is an integer. For an integer type the * operator is defined only to work with ints. So unless we have specified x to be of another type (in which case the compiler will throw an error) the compiler assumes the type of x to be int. The return value of int * int is int.</p>
<p>Now let us consider the expression x * y, where no type information has been specified for x and y. The compiler would expect the type of x and y to be something that has the operator &#8216;*&#8217; defined for the type. If we haven&#8217;t overloaded the * for any custom types, the compiler would have to select from a list of types for which * is predefined. Those would be the numerical types like int, float etc.<br />
In the absense of any additional type information to chose between them, the compiler defaults to int.</p>
<p>I should clarify that this is my guess, not a documented fact <img src='http://pradeepc.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binil Thomas</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-6001</link>
		<dc:creator>Binil Thomas</dc:creator>
		<pubDate>Wed, 23 Dec 2009 06:28:20 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-6001</guid>
		<description>I would have expected the type of 3 * x to the type of x.</description>
		<content:encoded><![CDATA[<p>I would have expected the type of 3 * x to the type of x.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pc</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-6000</link>
		<dc:creator>pc</dc:creator>
		<pubDate>Wed, 23 Dec 2009 04:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-6000</guid>
		<description>Your first comment went to the spam queue.  I have fixed it now.

You do make some interesting points.

For #1, in the context of the function that I wrote (i.e. in the absence of additional type information), x * 3 and 3 * x are both inferred as int. Why are you surprised with that? What else would you expect it to be ?

I will address your questions #2 and #3 in a separate post. You are correct in your assumptions on both.

#4 you are correct in your assertion.  It would have been a good way to explain both the concepts in a way they relate to each other.

Thanks for the comments mashe.</description>
		<content:encoded><![CDATA[<p>Your first comment went to the spam queue.  I have fixed it now.</p>
<p>You do make some interesting points.</p>
<p>For #1, in the context of the function that I wrote (i.e. in the absence of additional type information), x * 3 and 3 * x are both inferred as int. Why are you surprised with that? What else would you expect it to be ?</p>
<p>I will address your questions #2 and #3 in a separate post. You are correct in your assumptions on both.</p>
<p>#4 you are correct in your assertion.  It would have been a good way to explain both the concepts in a way they relate to each other.</p>
<p>Thanks for the comments mashe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pradeep</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-5995</link>
		<dc:creator>Pradeep</dc:creator>
		<pubDate>Mon, 21 Dec 2009 20:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-5995</guid>
		<description>Thanks for the suggestion, mashe. It does make sense. I will make that change now.</description>
		<content:encoded><![CDATA[<p>Thanks for the suggestion, mashe. It does make sense. I will make that change now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binil Thomas</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-5994</link>
		<dc:creator>Binil Thomas</dc:creator>
		<pubDate>Mon, 21 Dec 2009 18:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-5994</guid>
		<description>Also, instead of:
    let add2 = (add 2)

you might want to use the form:
    let addToTwo = (add 2)

which makes the subsequent expression
    addToTwo 8
clearer (readers might think that the &#039;2&#039; in &#039;add2&#039; has some significance).</description>
		<content:encoded><![CDATA[<p>Also, instead of:<br />
    let add2 = (add 2)</p>
<p>you might want to use the form:<br />
    let addToTwo = (add 2)</p>
<p>which makes the subsequent expression<br />
    addToTwo 8<br />
clearer (readers might think that the &#8217;2&#8242; in &#8216;add2&#8242; has some significance).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binil Thomas</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/comment-page-1/#comment-5993</link>
		<dc:creator>Binil Thomas</dc:creator>
		<pubDate>Mon, 21 Dec 2009 17:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/#comment-5993</guid>
		<description>Few points:

1) I am surprised that the compiler infers the type  of 3 * x to be int. What is the type of x * 3?

2) From the code you wrote, I think F# uses significant whitespace - you might want to explain that.

3) Functional programmers often use (tail) recursion to implement looping structures you might see in many other languages. The example you showed, I think, is not tail-recursive. Maybe something like:

let factorial num =
    let rec factInternal num prod =
        if (num &lt;= 1) then
            prod
        else
            factInternal(num-1, num*prod)
    factInternal(num, 1)

is more appropriate.

4) I am going to assume that the F# syntax for defining a temporary binding is:

let somefunc arg =
  let x = 1
  arg +x

Couple this with the statement that functions are &#039;first class&#039; and I think the nested function syntax follows naturally.

BTW, I don&#039;t know Jack about F#, so .. :-)</description>
		<content:encoded><![CDATA[<p>Few points:</p>
<p>1) I am surprised that the compiler infers the type  of 3 * x to be int. What is the type of x * 3?</p>
<p>2) From the code you wrote, I think F# uses significant whitespace &#8211; you might want to explain that.</p>
<p>3) Functional programmers often use (tail) recursion to implement looping structures you might see in many other languages. The example you showed, I think, is not tail-recursive. Maybe something like:</p>
<p>let factorial num =<br />
    let rec factInternal num prod =<br />
        if (num &lt;= 1) then<br />
            prod<br />
        else<br />
            factInternal(num-1, num*prod)<br />
    factInternal(num, 1)</p>
<p>is more appropriate.</p>
<p>4) I am going to assume that the F# syntax for defining a temporary binding is:</p>
<p>let somefunc arg =<br />
  let x = 1<br />
  arg +x</p>
<p>Couple this with the statement that functions are &#039;first class&#039; and I think the nested function syntax follows naturally.</p>
<p>BTW, I don&#039;t know Jack about F#, so .. <img src='http://pradeepc.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

