Export (0) Print
Expand All
Expand Minimize

Seq.forall2<'T1,'T2> Function (F#)

Tests whether all the pairs of elements drawn from the two sequences satisfy the given predicate. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.

Namespace/Module Path: Microsoft.FSharp.Collections.Seq

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
Seq.forall2 : ('T1 -> 'T2 -> bool) -> seq<'T1> -> seq<'T2> -> bool

// Usage:
Seq.forall2 predicate source1 source2


Type: 'T1 -> 'T2 -> bool

A function to test pairs of elements from the input sequences.


Type: seq<'T1>

The first input sequence.


Type: seq<'T2>

The second input sequence.




Thrown when either of the input sequences is null.

true if all element pairs in the sequences satisfy the given predicate. Otherwise, returns false.

This function is named ForAll2 in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

The following code shows how to use Seq.forall2.

// This function can be used on any sequence, so the same function 
// works with both lists and arrays. 
let allEqual coll = Seq.forall2 (fun elem1 elem2 -> elem1 = elem2) coll
printfn "%A" (allEqual [| 1; 2 |] [| 1; 2 |])
printfn "%A" (allEqual [ 1; 2 ] [ 2; 1 ])



Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

© 2015 Microsoft