Arrays and lists in F#

Recently, while exploring the capabilities of the F# programming language, I stumbled over the syntax for array creation and accessing elements of arrays. It looks like this.

let array = [|"foo"; "bar"; "baz"|]
printfn "%A" (array.[0])

Two things I find remarkable here. First, the array creation. Please note that you have a bar (or pipe) after the opening and before the closing square bracket. Second, you access elements of the array using dot notation plus brackets. Its the same for lists.

let list = ["foo"; "bar"; "baz"]
printfn "%A" (list.[0])

Note that you do not need the bars for creating lists. I find this dot notation for accessing elements of arrays and lists a bit annoying. For lists, you have the option of using a property to access elements like this.

printfn "%A" (list.Item(0))

However, I wonder why they do not support the plain bracket notation: array[0], list[0].

Comment