F#

一种开放源代码语言,利用它可轻松编写简洁、可靠且性能出色的代码。

开始

Windows、Linux 和 macOS 上均支持

// 'name' is inferred to be a string based on usage.
let printMessage name =
    printfn $"Hello there, {name}!"

// 'names' is inferred to be a sequence of strings.
let printNames names =
    for name in names do
        printMessage name

let names = [ "Ana"; "Felipe"; "Emillia" ]
printNames names
                                     
let square x = x * x
let isOdd x = x % 2 <> 0

let sumOfOddSquares nums =
    nums
    |> List.filter isOdd
    |> List.sumBy square

let numbers = [1; 2; 3; 4; 5]
let sum = sumOfOddSquares numbers

printfn "The sum of the odd squares in %A is %d" numbers sum
type Shape =
    | Square of side: double
    | Rectangle of width: double * length: double

let getArea shape =
    match shape with
    | Square side -> side * side
    | Rectangle (width, length) -> width * length

let square = Square 2.0
printfn $"The area of the square is {getArea square}"
                                   
type Customer(firstName, middleInitial, lastName) =
    member this.FirstName = firstName
    member this.MiddleInitial = middleInitial
    member this.LastName = lastName

    member this.SayFullName() =
        $"{this.FirstName} {this.MiddleInitial} {this.LastName}"

let customer = Customer("Emillia", "C", "Miller")

printfn $"Hello, I'm {customer.SayFullName()}!"
                                   

简洁、可靠且高性能

F# 具有轻量级语法,构建软件所需的代码非常少。它以强大的类型系统、方便的标准库和 .NET 运行时为后盾,用户可以信任它来构建正确、快速和可靠的任务关键型软件。

F# 入门

适用于数据科学和 ML 的 F#

F# 以多种方式使用,从构建最小的 Web API 到执行数据操作、交互式编程、数据科学和机器学习。

F# 的类型系统和独特的功能,例如类型提供程序度量单位非常适合数据科学和机器学习。

专业工具,无处不在

所有适用于 Windows, Linux, and macOS 的高质量编辑器都在单一 F# 编译器上运行,从而提供一致的高质量功能。

学习 F# 的工具

Microsoft + 社区

F# 是一种开源语言,Microsoft 是重要的参与者。独立的 F# Software Foundation 为 F# 社区提供了一个共同成长和学习的中心位置。

F# Software Foundation 网站

在 .NET 上运行

F# 为 .NET 开发者平台的一部分。请使用技能、代码和收藏的库生成所有类型的应用。

了解 .NET 平台

准备好开始使用了吗?

分步教程将帮助你在计算机上运行 F#。

开始