Догађаји
Изградите интелигентне апликације
17. мар 21 - 21. мар 10
Придружите се серији састанака како бисте изградили скалабилна АИ решења заснована на стварним случајевима коришћења са колегама програмерима и стручњацима.
Региструјте се одмахОвај прегледач више није подржан.
Надоградите на Microsoft Edge бисте искористили најновије функције, безбедносне исправке и техничку подршку.
F# 4.6 adds multiple improvements to the F# language.
F# 4.6 is available in all .NET Core distributions and Visual Studio tooling. Get started with F# to learn more.
Anonymous records are a new kind of F# type introduced in F# 4.6. They are simple aggregates of named values that don't need to be declared before use. You can declare them as either structs or reference types. They're reference types by default.
open System
let getCircleStats radius =
let d = radius * 2.0
let a = Math.PI * (radius ** 2.0)
let c = 2.0 * Math.PI * radius
{| Diameter = d; Area = a; Circumference = c |}
let r = 2.0
let stats = getCircleStats r
printfn "Circle with radius: %f has diameter %f, area %f, and circumference %f"
r stats.Diameter stats.Area stats.Circumference
They can also be declared as structs for when you want to group value types and are operating in performance-sensitive scenarios:
open System
let getCircleStats radius =
let d = radius * 2.0
let a = Math.PI * (radius ** 2.0)
let c = 2.0 * Math.PI * radius
struct {| Diameter = d; Area = a; Circumference = c |}
let r = 2.0
let stats = getCircleStats r
printfn "Circle with radius: %f has diameter %f, area %f, and circumference %f"
r stats.Diameter stats.Area stats.Circumference
They're quite powerful and can be used in numerous scenarios. Learn more at Anonymous records.
The ValueOption type added in F# 4.5 now has "module-bound function parity" with the Option type. Some of the more commonly-used examples are as follows:
// Multiply a value option by 2 if it has value
let xOpt = ValueSome 99
let result = xOpt |> ValueOption.map (fun v -> v * 2)
// Reverse a string if it exists
let strOpt = ValueSome "Mirror image"
let reverse (str: string) =
match str with
| null
| "" -> ValueNone
| s ->
str.ToCharArray()
|> Array.rev
|> string
|> ValueSome
let reversedString = strOpt |> ValueOption.bind reverse
This allows for ValueOption to be used just like Option in scenarios where having a value type improves performance.
.NET повратне информације
.NET је пројекат отвореног кода. Изаберите везу да бисте обезбедили повратне информације:
Догађаји
Изградите интелигентне апликације
17. мар 21 - 21. мар 10
Придружите се серији састанака како бисте изградили скалабилна АИ решења заснована на стварним случајевима коришћења са колегама програмерима и стручњацима.
Региструјте се одмахОбука
Путања учења
Primeros pasos con F# - Training
F# es un lenguaje de programación multiplataforma de código abierto que facilita la escritura de código concisa, eficaz, sólida y práctica. Se trata de un lenguaje de uso general que permite crear muchos tipos diferentes de aplicaciones, como API web, Escritorio, IoT, Juegos, etc.