maxBy - Projection

Category:
LINQ
Description: This sample uses Max to get the length of the longest word in an array.
Code:
let LINQ35() =
let words = ["cherry"; "apple"; "blueberry"]
let longestLength =
query {
for w in words do
maxBy w.Length
}
printfn "The longest word is %A characters long." longestLength

//sample output
// The longest word is 9 characters long.


Execution Result:
The longest word is 9 characters long.

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

Comments

No comments yet.