This project is read-only.
count - Conditional

Category:
LINQ
Description: This sample uses Count to get the number of odd ints in the array.
Code:
let LINQ29() =
let numbers = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

let oddNumbers = numbers.Count(fun n -> n % 2 = 1)
printfn "There are %A odd numbers in the list." oddNumbers

//sample output
// There are 5 odd numbers in the list.


Execution Result:
There are 5 odd numbers in the list.

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

Comments

No comments yet.