Array.iteri <'T> Funkcja (F#)
Dotyczy dana funkcja każdy element tablicy.Liczba całkowita, przekazany do funkcji wskazuje indeks elementu.
Ścieżka obszaru nazw/modułu: Microsoft.FSharp.Collections.Array
Zgromadzenie: FSharp.Core (w FSharp.Core.dll)
// Signature:
Array.iteri : (int -> 'T -> unit) -> 'T [] -> unit
// Usage:
Array.iteri action array
Parametry
action
Type: int -> 'T -> unitFunkcja stosuje się do każdego indeksu i element.
array
Type: 'T[]Tablicy wejściowy.
Uwagi
Ta funkcja o nazwie [IterateIndexed] w skompilowane zestawy.Jeżeli języka, niż F# lub przez odbicie, uzyskują dostęp do funkcji, należy użyć tej nazwy.
Przykład
Następujące przykłady kodu pokazano różnice między Array.iter, Array.iter2, Array.iteri, i Array.iteri2.
let array1 = [| 1; 2; 3 |]
let array2 = [| 4; 5; 6 |]
Array.iter (fun x -> printfn "Array.iter: element is %d" x) array1
Array.iteri(fun i x -> printfn "Array.iteri: element %d is %d" i x) array1
Array.iter2 (fun x y -> printfn "Array.iter2: elements are %d %d" x y) array1 array2
Array.iteri2 (fun i x y ->
printfn "Array.iteri2: element %d of array1 is %d element %d of array2 is %d"
i x i y)
array1 array2
Dane wyjściowe
Platformy
Windows 8, Windows 7, Windows Server 2012 Windows Server 2008 R2
Informacje o wersji
F# Core wersji biblioteki
Obsługiwane: 2.0, 4.0, przenośne