This project is read-only.
sumBy - Simple

Category:
LINQ
Description: This sample uses Sum to get the total of the numbers in an array.
Code:
let LINQ30() =
let numbers = [ 5; 4; 1; 3; 9; 8; 6; 7; 2; 0 ]

let numSum =
query {
for n in numbers do
sumBy n
}
printfn "The sum of the numbers is %A." numSum

//sample output
// The sum of the numbers is 45.

Execution Result:
The sum of the numbers is 45.

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

Comments

No comments yet.