F# is an open-source, cross-platform programming language that makes it easy to write succinct, performant, robust, and practical code.
F# is a multiparadigm language that supports both object programming and functional programming. It also hooks into the .NET ecosystem which means that with it, you can build apps like
There are many language features and aspects of the F# language that make it easy to be productive when writing code:
There are a few things you need to get started.
You can start writing F# by using the REPL called FSI, you can also scaffold an F# project using the dotnet
executable.
You create a project using dotnet
like so:
dotnet new console --language F# -o MyFSharpApp
Then you get a project with files:
Here you have the code of Program.fs. Itt contains the functions from()
and main()
. main()
is the entry point of the app, as seen by [<EntryPoint>]
.
open System
// Define a function to construct a message to print
let from whom =
sprintf "from %s" whom
[<EntryPoint>]
let main argv =
let message = from "F#" // Call the function
printfn "Hello world %s" message
0 // return an integer exit code
The from()
function takes the arg whom
and the function body prints a string using the function sprintf
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.