List.forall<'T> Function (F#)
Tests if all elements of the collection satisfy the given predicate.
Namespace/Module Path: Microsoft.FSharp.Collections.List
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
List.forall : ('T -> bool) -> 'T list -> bool
// Usage:
List.forall predicate list
Parameters
predicate
Type: 'T -> boolThe function to test the input elements.
list
Type: 'T listThe input list.
Return Value
true if all of the elements satisfy the predicate. Otherwise, returns false.
Remarks
The predicate is applied to the elements of the input list. If any application returns false then the overall result is false and no further elements are tested. Otherwise, true is returned.
This function is named ForAll in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.
Example
The following code example illustrates the use of List.forall.
let isAllZeroes list = List.forall (fun elem -> elem = 0.0) list
printfn "%b" (isAllZeroes [0.0; 0.0])
printfn "%b" (isAllZeroes [0.0; 1.0])
Output
true false
Platforms
Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2
Version Information
F# Runtime
Supported in: 2.0, 4.0
Silverlight
Supported in: 3