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 26, 2019
·
5 revisions
COMPOSITION
takes a set of functions as its arguments and returns a function that is the result of the sequential application of those functions, evaluating the rightmost expression first and yielding the result to the next function (directly to the left of the function just executed).
COMPOSITION(args...)
- args is a set of functions
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"]
.