title | description | keywords | author | manager | ms.date | ms.topic | ms.prod | ms.technology | ms.assetid |
---|---|---|---|---|---|---|---|---|---|
List.iteri2<'T1,'T2> Function (F#) |
List.iteri2<'T1,'T2> Function (F#) |
visual f#, f#, functional programming |
dend |
danielfe |
05/16/2016 |
language-reference |
visual-studio-dev14 |
devlang-fsharp |
183c14eb-67b1-4550-a5ec-a417a61261a9 |
Applies the given function to two lists simultaneously. The lists must have equal lengths. The integer passed to the function indicates the index of element.
Namespace/Module Path: Microsoft.FSharp.Collections.List
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
List.iteri2 : (int -> 'T1 -> 'T2 -> unit) -> 'T1 list -> 'T2 list -> unit
// Usage:
List.iteri2 action list1 list2
action Type: int-> 'T1 -> 'T2 ->unit
The function to apply to a pair of elements from the input lists along with their index.
list1 Type: 'T1list
The first input list.
list2 Type: 'T2list
The second input list.
Exception | Condition |
---|---|
ArgumentException | Thrown when the input lists differ in length. |
This function is named IterateIndexed2
in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.
The following code example illustrates the use of List.iteri2 and compares its behavior with related functions.
[!code-fsharpMain]
Output
List.iter: element is 1
List.iter: element is 2
List.iter: element is 3
List.iteri: element 0 is 1
List.iteri: element 1 is 2
List.iteri: element 2 is 3
List.iter2: elements are 1 4
List.iter2: elements are 2 5
List.iter2: elements are 3 6
List.iteri2: element 0 of list1 is 1 element 0 of list2 is 4
List.iteri2: element 1 of list1 is 2 element 1 of list2 is 5
List.iteri2: element 2 of list1 is 3 element 2 of list2 is 6
Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2
F# Core Library Versions
Supported in: 2.0, 4.0, Portable