Array
F# Array type is a data collection where elements are contiguous and has random access in constant time (see Wikipedia article about arrays).
Examples
> [|1 .. 10|];; val it : int array = [|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|] > [|1 .. +2 .. 10|];; val it : int array = [|1; 3; 5; 7; 9|] > let arr = [|1 .. +4 .. 30|];; val arr : int array > arr.[2..5];; val it : int [] = [|9; 13; 17; 21|] > Array.map (fun x -> x * x) arr;; val it : int [] = [|1; 25; 81; 169; 289; 441; 625; 841|] > Array.filter (fun x -> x % 3 = 0) arr;; val it : int [] = [|9; 21|] > Array.sort_by string arr;; val it : unit = () > arr;; val it : int array = [|1; 13; 17; 21; 25; 29; 5; 9|] > Array.fold_left (fun acc x -> acc + string x + " ") "" arr;; val it : string = "1 5 9 13 17 21 25 29 "
See also
- Arrays in F# (Marius Bancila)