Training
Module
Store and apply operations on list data in F# - Training
This module covers collections in F#, with a specific focus on lists.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
List.TransformMany(list as list, collectionTransform as function, resultTransform as function) as list
Returns a list whose elements are projected from the input list.
The collectionTransform
function transforms each element into an intermediate list, and the resultTransform
function receives the original element as well as an item from the intermediate list in order to construct the final result.
The collectionTransform
function has the signature (x as any) as list => ...
, where x
is an element in list
. The resultTransform
function projects the shape of the result and has the signature (x as any, y as any) as any => ...
, where x
is an element in list
and y
is an element from the list generated by passing x
to collectionTransform
.
Flatten a list of people and their pets.
Usage
List.TransformMany(
{
[Name = "Alice", Pets = {"Scruffy", "Sam"}],
[Name = "Bob", Pets = {"Walker"}]
},
each [Pets],
(person, pet) => [Name = person[Name], Pet = pet]
)
Output
{
[Name = "Alice", Pet = "Scruffy"],
[Name = "Alice", Pet = "Sam"],
[Name = "Bob", Pet = "Walker"]
}
Training
Module
Store and apply operations on list data in F# - Training
This module covers collections in F#, with a specific focus on lists.