Fsharp: String Operations

By Xah Lee. Date: . Last updated: .

String Index

syntax

str[n]

or

str.[n]

🛑 WARNING: negative index not supported.

let xx = "abc"[0]
printfn "%c" xx
// a

String Slice (substring)

syntax

str[n..m]

inclusive.

let xx = "0123456"[0..3]
printfn "%s" xx
// 0123

Join String

str + str

printfn "%s" ("abc" + "def")
// abcdef

Fsharp, String