你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu 中的编程语言

F#

[日期:2010-08-11] 来源:Ubuntu社区  作者:skyivben [字体:大 中 小]

F#
F# 语言在2010年6月编程语言排行榜中排名第四十五位。下面就是 GregorianTest.fs 程序:

1:  let dt = System.DateTime(1582, 10, 4)
2:  printfn "%s" (dt.ToString("dddd yyyy-MM-dd"))
3:  printfn "%s" (dt.AddDays(1.0).ToString("dddd yyyy-MM-dd"))

安装 F# 编译器:

ben@ben-1520:~/work$ wget http://download.microsoft.com/
download/1/3/B/13BE2B98-E487-4032-9441-22D4D2F4FAAC/fsharp.zip
ben@ben-1520:~/work$ sudo unzip -q fsharp.zip -d /usr/local/bin/
ben@ben-1520:~/work$ rm fsharp.zip
ben@ben-1520:~/work$ cd /usr/local/bin/FSharp-2.0.0.0
ben@ben-1520:/usr/local/bin/FSharp-2.0.0.0$ sudo chmod +x install-mono.sh
ben@ben-1520:/usr/local/bin/FSharp-2.0.0.0$ sudo wget http://anonsvn.mono-project.com/
source/trunk/mcs/class/mono.snk
ben@ben-1520:/usr/local/bin/FSharp-2.0.0.0$ sudo ./install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
Assembly bin/FSharp.Core.dll signed.
-- Installing FSharp DLLS into the GAC
Installed bin/FSharp.Core.dll into the gac (/usr/lib/mono/gac)
ben@ben-1520:/usr/local/bin/FSharp-2.0.0.0$ cd ~/work
ben@ben-1520:~/work$ cat >> ~/.bashrc <<!
>
> # set PATH for Microsoft F#
> if [ -d "/usr/local/bin/FSharp-2.0.0.0/bin" ] ; then
>     PATH="/usr/local/bin/FSharp-2.0.0.0/bin:\$PATH"
> fi
> !
ben@ben-1520:~/work$ exit

 
fsi.exe 是 F# 交互窗口,fsc.exe 是 F# 编译器:

ben@ben-1520:~/work$ fsi.exe
Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> System.Environment.OSVersion;;
val it : System.OperatingSystem =
  Unix 2.6.32.22 {Platform = Unix;
                  ServicePack = "";
                  Version = 2.6.32.22;
                  VersionString = "Unix 2.6.32.22";}
> #quit;;
- Exit...
ben@ben-1520:~/work$ fsc.exe GregorianTest.fs
Microsoft (R) F# 2.0 Compiler build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
ben@ben-1520:~/work$ ./GregorianTest.exe
星期一 1582-10-04
星期二 1582-10-05
ben@ben-1520:~/work$

 
运行结果和 GregorianTest.cs 的一样。但 F# 源程序比 C# 源程序更简洁。

linux
【内容导航】
第1页:Java 第2页:Scala
第3页:Visual Basic.NET 第4页:C#
第5页:F# 第6页:C
第7页:C++ 第8页:Python
第9页:Ruby 第10页:JavaScript
第11页:Perl 第12页:PHP
第13页:Pascal 第14页:Delphi
第15页:Fortran 第16页:Lua
第17页:Lisp 第18页:Logo
相关资讯       Linux编程  Ubuntu编程 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用���的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* long 发表于 2010/8/14 23:47:54
赞