select - Simple

Category:
LINQ
Description: This sample uses select to produce a sequence of ints one higher than those in an existing array of integers.
Code:
let LINQ07() =
let numbers = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

query {
for n in numbers do
select (n + 1)
} |> Seq.iter(fun n -> printfn "%d" n)

//sample output
// 6
// 5
// 2
// 4
// 10
// 9
// 7
// 8
// 3
// 1


Execution Result:
6
5
2
4
10
9
7
8
3
1

Last edited Sep 15, 2011 at 2:32 PM by Jackhu, version 3

Comments

No comments yet.