This project is read-only.
sumBy - Projection

Category:
LINQ
Description: This sample uses Sum to get the total number of characters of all words in the array.
Code:
let LINQ31() =
let words = ["cherry"; "apple"; "blueberry"]

let totalChars =
query {
for w in words do
sumBy (w.Length)
}
printfn "There are a total of %A characters in these words." totalChars

//sample output
// There are a total of 20 characters in these words.


Execution Result:
There are a total of 20 characters in these words.

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

Comments

No comments yet.