F#
v5.0.201
F#
v5.0.201
F# is a strongly typed, functional-first programming language on the .NET platform. It combines concise, expression-oriented syntax with powerful type inference, immutability by default, discriminated unions, pattern matching, and seamless interop with the rest of .NET. CompileBytes builds and runs F# with the .NET SDK toolchain version 5.0.201, so you can write idiomatic functional code and execute it in the browser without configuring a project.
While F# embraces functional programming, it is fully multi-paradigm and supports objects, classes, and imperative code when needed. Features such as pipelines with the |> operator, lightweight records, and computation expressions make it expressive for data processing, scripting, and application logic. Because it runs on .NET, F# programs have access to the large Base Class Library and the broader NuGet ecosystem.
printfn "Hello, World!"let square x = x * x
printfn "%d" (square 7)[1..5]
|> List.map (fun x -> x * x)
|> List.iter (printfn "%d")let describe n =
match n with
| 0 -> "zero"
| x when x < 0 -> "negative"
| _ -> "positive"
printfn "%s" (describe -3)let rec factorial n =
if n <= 1 then 1
else n * factorial (n - 1)
printfn "%d" (factorial 6)type Shape =
| Circle of float
| Rectangle of float * float
let area shape =
match shape with
| Circle r -> 3.14159 * r * r
| Rectangle (w, h) -> w * h
printfn "%.2f" (area (Circle 2.0))type Person = { Name: string; Age: int }
let p = { Name = "Ada"; Age = 36 }
printfn "%s is %d" p.Name p.Agelet safeDiv a b =
if b = 0 then None
else Some (a / b)
match safeDiv 10 2 with
| Some r -> printfn "%d" r
| None -> printfn "cannot divide"let nums = [1; 2; 3; 4; 5]
let total = List.fold (+) 0 nums
printfn "Sum: %d" totalYes. CompileBytes compiles and runs your F# code on the server using the .NET SDK, so you can try the language in your browser without installing .NET or an IDE.
Programs are built with the .NET SDK 5.0.201 toolchain, which provides the F# compiler and the .NET 5 runtime and base class library.
Use System.Console.ReadLine() to read a line of text from standard input. Anything you place in the stdin box is delivered to your program through the console input stream.
Yes. F# and the .NET SDK are free and open source, maintained by Microsoft and the F# Software Foundation, and using them here costs nothing.
The forward-pipe operator |> passes the value on its left as the last argument to the function on its right, letting you chain transformations left to right, as in data |> List.map f |> List.sum.