摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming1. 声明变量1.1 值是值,变量是变量在F#里最常见的关键字就是let,用来声明变量或是函数。 举例如下:let x = 5let y = 10let z = x + y这样就声明了x,y,然后分别赋值。最后z等于x加y的值。 然后你可以再把它们打印出来printfn "x: %i" xprintfn "y: %i" yprintfn "z: %i" z最后输出的结果是什么,到FSI里试下就知道了。 记得不要忘记,在FSI里要在 阅读全文
posted @ 2013-01-28 22:24 Functional Life 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming2. 声明函数声明一个函数用的也是let,后面函数名和函数体,用空格间隔开来let add x y = x + ylet z = add 5 10定义一个叫add的函数,接受两个参数,然后返回相加的结果。这里z就等于15了。那如果我这样调用呢?let z = add 5 10.2也许你会说z等于15.2吧,其实这里你会得到一个错误error FS0001: This expression was expected to have type intbut here has type ... 阅读全文
posted @ 2013-01-28 22:24 Functional Life 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming先下载F#:http://www.microsoft.com/en-us/download/details.aspx?id=11100最低要求.NET2.0环境。安装好了以后把BIN目录加入环境变量里。两个主要的东西,一个是FSI,交互式的SHELL。一个是FSC,用来编译F#代码的。运行FSI,如下图所示。Microsoft F# Interactive, (c) Microsoft Corporation, All Rights ReservedF# Version 1.9.6.2, 阅读全文
posted @ 2013-01-28 22:20 Functional Life 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Don't pity the humble programmer. He can be lord of all things.Whatever exists in the universe, he has first in his mind, and then in his hand.By his code, he may be called a grandchild of god. 阅读全文
posted @ 2013-01-28 22:19 Functional Life 阅读(169) 评论(0) 推荐(0) 编辑