This project is read-only.
takeWhile - simple

Category:
LINQ
Description: This sample uses TakeWhile to return elements starting from the beginning of the array until a number is hit that is not less than 6.
Code:
let LINQ17() =
let numbers = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

query {
for n in numbers do
takeWhile (n < 6)
} |> Seq.iter(fun n -> printfn "%A" n)

//sample output
// 5
// 4
// 1
// 3


Execution Result:
5
4
1
3

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

Comments

No comments yet.