标签:hello .com family def record sprintf 异步编程 with draw
F#是一种函数式编程语言,可以轻松编写正确且可维护的代码。
F#编程主要涉及定义类型推断和自动泛化的类型和函数。 这使您可以将焦点保留在问题域上并操纵其数据,而不是编程的细节。
open System // Gets access to functionality in System namespace. // Defines a function that takes a name and produces a greeting. let getGreeting name = sprintf "Hello, %s! Isn‘t F# great?" name [<EntryPoint>] let main args = // Defines a list of names let names = [ "Don"; "Julia"; "Xi" ] // Prints a greeting for each name! names |> List.map getGreeting |> List.iter (fun greeting -> printfn "%s" greeting) 0
F#有许多功能,包括:
// Group data with Records type SuccessfulWithdrawal = { Amount: decimal Balance: decimal } type FailedWithdrawal = { Amount: decimal Balance: decimal IsOverdraft: bool } // Use discriminated unions to represent data of 1 or more forms type WithdrawalResult = | Success of SuccessfulWithdrawal | InsufficientFunds of FailedWithdrawal | CardExpired of System.DateTime | UndisclosedFailure
F#记录和区分联合在默认情况下是非null,不可变和可比较的,使它们非常容易使用。完整教程阅读http://nopapp.com/Blog/Article/FSharp-What-Is-FSharp
标签:hello .com family def record sprintf 异步编程 with draw
原文地址:https://www.cnblogs.com/bruceday/p/9868061.html