nth

Category:
LINQ
Description: This sample uses ElementAt to retrieve the second number greater than 5 from an array.
Code:
let LINQ27() =
let numbers2 = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

let fourthLowNum =
query {
for n in numbers2 do
where (n > 5)
nth 1
}
printfn "Second number > 5: %A" fourthLowNum

//sample output
// Second number > 5: 8


Execution Result:
Second number > 5: 8

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

Comments

No comments yet.