Using a functional map to reorder data

Use a functional map to arrange data in a different order. For example, you are growing some flowers and tracking their progress. You have some data for the measurements you took: height, number of leaves, water intake, and so on. These ProgressReadings are in no particular order in your input data. For example, the readings for daisy are scattered throughout the input data.

Shown below is some input data:









You want to generate an output that consists of reports, one for each flower type. You want a report for alstromeria, one for daisies, one for snapdragons, and so on. Use a functional map called MakeReport, to produce one report per flower type.

To create a report for each flower type, you need to determine the different kinds of flowers in the input data. To do this, use the UNIQUE function. The UNIQUE function looks at all of the values for a given data object and returns the unique values.

In the input data, the object called Flower indicates the flower type. Use the UNIQUE function on Flower as the first input argument to the map F_MakeReport. This will cause the map F_MakeReport to be executed once for each flower type.

In the input data, the unique flowers are alstromeria, daisy, snapdragon, lily, and iris. In each output report for a given flower type, you want all of the ProgressReadings for that flower type, which are scattered throughout the entire input data. To get all of these ProgressReadings, you will use the entire input object as the second argument to the map F_MakeReport.