F#

维基百科,自由的百科全书

(重定向自F#)
跳转到: 导航, 搜索

F#是由微软发展的为微软.NET语言提供运行环境的程序设计语言。它是基于OCaml的,而OCaml是基于ML函数程式语言的。

这是一个用于显示.NET在不同编程语言间互通的程序设计。

2007年7月31日释出1.9.2.9版。

[编辑] 范例

一些小小范例如下:

(* This is a comment *)
(* Sample hello world program *)
printf "Hello World!"
#light
open Microsoft.FSharp.Collection.List
(* print a list of numbers recursively *)
let rec printlist l =
    (* When using "#light", you must indent with 4 spaces *)
    if l = [] then
    else
        printf "%d\n" (nth l 0)
        printlist (tl l)
#light
(* Sample Windows Forms Program *)

(* We need to open the Windows Forms library *)
open System.Windows.Forms

(* Create a window and set a few properties *)
let form = new Form(Visible=true, TopMost=true, Text="Welcome to F#")

(* Create a label to show some text in the form *)
let label =
    let temp = new Label()
    let x = 3 + (4 * 5)
    (* Set the value of the Text*)
    temp.Text <- x
    (* Remember to return a value! *)
    temp

(* Add the label to the form *)
do form.Controls.Add(label)

(* Finally, run the form *)
do Application.Run(form)

F# 相容于 XNA Game Studio Express 产品,可允许在 Xbox 360上建构游戏软体。

[编辑] 外部链接

个人工具