where - Simple

Category:
LINQ
Description: This sample uses where to find all elements of an array less than 5.
Code:
let LINQ01() =
let numbers = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

query {
for n in numbers do
where (n < 5)
select n;
} |> Seq.iter(fun n -> printfn "%A" n)

// sample output
// 4
// 1
// 3
// 2
// 0


Execution Result:
4
1
3
2
0

Last edited Sep 15, 2011 at 2:30 PM by Jackhu, version 4

Comments

No comments yet.