F#

F#是由微软发展的为.NET语言提供运行环境的程序设计语言,是函數程式語言FP,Functional Programming),函數程式語言最重要的基礎是Lambda Calculus。它是基于OCaml的,而OCaml是基于ML函数程式语言。有時F#和OCaml的程式是可以交互編譯的。

F#
多范型: 函數程式語言, 指令式編程, 面向对象編程, 元编程, 并发计算
設計者微软研究院, Don Syme
實作者微软, The F# Software Foundation
2005年 (2005) (version 1.0)
穩定版本
4.1[1]
(2017年3月8日2017-03-08
型態系統静态类型, 强类型, 类型推论
作業系統跨平台 (.NET框架, Mono, JavaScript)
許可證Apache许可证
文件扩展名.fs, .fsi, .fsx, .fsscript
網站fsharp.org
啟發語言
ML, OCaml, C#, Python, Haskell,[2] Scala, Erlang
影響語言
F*, LiveScript

F#已經接近成熟,支援高阶函数、柯里化惰性求值、Continuations、模式匹配、闭包、列表处理和元编程。这是一个用于显示.NET在不同编程语言间互通的程序设计,可以被.NET中的任意其它代碼編譯和調用。

2002年微软開始由Don Syme帶領研發F#,從C#,LINQHaskell中獲取了經驗,2005年推出第一個版本,2007年7月31日释出1.9.2.9版。2007年底,微軟宣布F#進入產品化的階段。

F#已被集成在Visual Studio 2010中,版本是2.0,含有对.Net Framework的完全支持。

F#现在在Visual Studio 2015中,版本是4.0。

F#现在在Visual Studio 2017中,版本是4.1。

范例

一些小小范例如下:

(* 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上建构游戏软件。

参考文献

  1. https://github.com/fsharp/fsharp/releases
  2. Syme, Granicz & Cisternino (2007:2) "F# also draws from Haskell particularly with regard to two advanced language features called sequence expressions and workflows."

外部链接

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.