This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
COMPOSITION
Daniel Gorman edited this page Sep 24, 2019
·
5 revisions
COMPOSITION
takes a set of functions as its argument and returns a function that is the product of the sequential application of those functions. Takes an indeterminate number of arguments (the rightmost function will evaluate them) and yields the result to the next function (directly to the left of the function just executed).
COMPOSITION(args...)
- args is a set of arguments to be passed to the rightmost function passed to
COMPOSITION
.
Let's say we want to design a function that joins two strings and then capitalizes the result. Given the following data sample:
{
"user_one": {
"first_name": "Andrey",
"last_name": "Rudenko"
},
"user_two": {
"first_name": "Kirill",
"last_name": "Chernyshov"
}
}
We could write the function MAP(composition(UPPER, CONCATENATE), [[user_one.first_name, user_one,last_name], [user_two.first_name, user_two.last_name]])
.
This would return: ["ANDREYRUDENKO","KIRILLCHERNYSHOV"]
.