This simple example demonstrates how to use the "sum" function of the Seq module. In this example, four integers are added together. The result is then squared.
Note: I have chosen to write these sample tests in C# to help emphasis the interoperability of the languages. These tests could have just as easily been written in F#. For examples of this, check out the book Expert F#.
public void CanCalculateSeqExample()
List<int> numbersToCalculate = new List<int>();
int result = FSharpSample.CalculateSeqExample(numbersToCalculate);
let CalculateNumberSquared x = x*x
let CalculateSeqExample args =
Seq.sum args |> CalculateNumberSquared
val CalculateNumberSquared: int -> int
val CalculateSeqExample: seq
While this example is very simple, it provides a brief view into the power that some of these modules provides. This example also shows how functions can be chained together. The astute observer will have noticed the "|>" operator in the