Fsharp: Print

By Xah Lee. Date: . Last updated: .

Print

// print
printf "abc"
printf "def"
// abcdef

print with added newline

// print with added newline at end
printfn "abc"
printfn "def"

Print string

// string
printfn "%s" "Alice"
// Alice

Print integer

// number
printfn "%d" 344
// 344

Print floating number

// float number
printfn "%f" (1. / 3.)
// 0.333333

Print tuple, list, array, sequence

let xtuple = ("Alice", 30, true)
printfn "%A" xtuple
// ("Alice", 30, true)
let xlist = [1; 2; 3]
printfn "%A" xlist
let xseq = seq { 1..5 }
printfn "%A" xseq
// seq [1; 2; 3; 4; ...]

Format String

Fsharp, String