-
Book Overview & Buying
-
Table Of Contents
F# 4.0 Design Patterns
By :
In the simplest case, consider that I use the analogy of set product to combine types A and B; the result would be a set of data pairs where the first pair constituent is of type A, the second constituent is of type B, and the whole combination is a Cartesian product of A and B.
F# offers two product algebraic data types, that is, tuples and records.
I have already touched tuples in previous chapters; now I'll go deeper into this subject.
A tuple is a combination of two or more values of any type. The tuple value element type can be of anything: primitive types, other tuples, custom classes, and functions. For example, take a look at the following code line (Ch5_1.fsx):
let tuple = (1,"2",fun() ->3)
This represents a tuple assembled from three elements of type int* string * (unit -> int).
In order to belong to the same type of tuple, two tuple values must have the same number of elements with the similar types in the order of occurrence...
Change the font size
Change margin width
Change background colour