Code · 1 file
Sample F# File
F# is a functional-first .NET language. The F# sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.
F# · 508 B
Sample F# file
An idiomatic F# example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.
CC0 · free for any use · Verified by an independent tool · Report a problem
// Sample F# script — samplefiles.com
type Customer = { Id: int; Name: string; Balance: decimal }
let isVip c = c.Balance >= 10_000m
let totalBalance = List.sumBy (fun c -> c.Balance)
let customers =
[ { Id = 1; Name = "Ada"; Balance = 12_500m }
{ Id = 2; Name = "Grace"; Balance = 830.5m }
{ Id = 3; Name = "Linus"; Balance = 10_000m } ]
for c in customers do
printfn "%-6s %10.2f %s" c.Name c.Balance (if isVip c then "VIP" else "")
printfn "Total: %.2f" (totalBalance customers)File details
Download from the command line
curl -L -o sample.fs https://files.samplefiles.com/code/fs/sample.fswget https://files.samplefiles.com/code/fs/sample.fshttps://files.samplefiles.com/code/fs/sample.fsprintf '%s %s\n' 007350746d23d91136cfd5dec39ee19b3cdbece3670e81449079dda778bd4b70 sample.fs | shasum -a 256 -cOr check the download in your browser with the checksum calculator.