-
Notifications
You must be signed in to change notification settings - Fork 1
Higher order functions
The concept of higher-order functions are fundamental to Meld's design. The Wikipedia definition of a higher-order function is:
A function that does at least one of the following:
- takes one or more functions as arguments, which is a parameter of a procedure that is itself a procedure,
- returns a function as its result.
The first item above applies for framework contexts. In particular, the framework user supplies a function
where
Consider the graph below (previously described here):
![](https://private-user-images.githubusercontent.com/7603566/237214232-b0c93b3c-8308-4529-90dd-bac0dc193845.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjEzOTksIm5iZiI6MTcyNTc2MTA5OSwicGF0aCI6Ii83NjAzNTY2LzIzNzIxNDIzMi1iMGM5M2IzYy04MzA4LTQ1MjktOTBkZC1iYWMwZGMxOTM4NDUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MDhUMDIwNDU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGUwMmY4YjdlOWEzOTkxYzhiNDRlNDBkZmVlM2ExMjAyZGM4OGMwZWU1MDFjYjE4YmM0OTMxNjMwZTNiMTIzZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.r1cQCqL4SsOdgRu1RUaqLUiJEmW_EYTomyMXSVLDV00)
There are three explicit domains in the above figure:
-
$\mathcal{R}$ , which corresponds to a run, -
$\mathcal{S_\alpha}$ , which corresponds to a collection of subruns, and -
$\mathcal{E_n}$ , which corresponds to a collection of events.
The mappings depicted in the graph above are representable mathematically as:
-
$\left\{(a)_8 \xrightarrow{f} (b)_8\right\} \in \mathcal{E_n}$ (transform), -
$\left\{(c)_8 \xrightarrow{g_0} (K)_4\right\} \in \mathcal{S_\alpha}$ (reduction), -
$\left\{(J,K)_4 \xrightarrow{h_0} (W)_1\right\} \in \mathcal{R}$ (reduction), where the sequences$(J)_4$ and$(K)_4$ are zipped together and presented as a pair to the function$h_0$ .
Observe that for reductions, the arrow connecting two sequences crosses one or more boundaries from a more nested domain to a higher one. For splitters, the arrow is reversed and it connects two sequences by crossing one or more boundaries from a higher domain to a more nested one.
Note: The domain of each input argument to the user function
Meld's supported higher-order functions are shown in the table below.
Higher-order function | Product sequence mapping | User operation |
---|---|---|
Transform (map) | ||
Filter | ||
Monitor | ||
Reduction (fold) | ||
Splitter (unfold) |