F# Tip Of The Week (30 September 2013)

A method in the Seq class can be applied to any kind of IEnumerable.  Consider the following code:

let sum l = l |> Seq.reduce (+)

let testArray = [|1..10|]
let testList = [1..10]
let testSeq = seq { 1..10 }

let aSum = sum testArray //55
let lSum = sum testList //55
let sSum = sum testSeq //55

One response

  1. Pingback: F# Weekly #40, 2013 | Sergey Tihon's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: