all - simple

Category:
LINQ
Description: This sample uses All to determine whether an array contains only odd numbers.
Code:
let LINQ14() =
let numbers = [1;11;3;19;41;65;19]

let onlyOdd =
query {
for n in numbers do
all (n % 2 = 1)
}
printfn "The list contains only odd numbers: %A" onlyOdd

//sample output
// The list contains only odd numbers: true



Execution Result:
The list contains only odd numbers: true

Last edited Sep 14, 2011 at 1:44 AM by ttliu2000, version 1

Comments

No comments yet.