This project is read-only.
averageBy - Simple

Category:
LINQ
Description: This sample uses Average to get the average of all numbers in an array.
Code:
let LINQ36() =
let numbers2 = [5.0; 4.0; 1.0; 3.0; 9.0; 8.0; 6.0; 7.0; 2.0; 0.0]
let averageNum =
query {
for n in numbers2 do
averageBy n
}
printfn "The average number is %A." averageNum

//sample output
// The average number is 4.5.

Execution Result:
The average number is 4.5.

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

Comments

No comments yet.