RosettaCodeData/Task/First-class-functions/00DESCRIPTION

19 lines
1.1 KiB
Plaintext

A language has [[wp:First-class function|first-class functions]] if it can do each of the following without recursively invoking a compiler or interpreter or otherwise [[metaprogramming]]:
* Create new functions from preexisting functions at run-time
* Store functions in collections
* Use functions as arguments to other functions
* Use functions as return values of other functions
<br>
;Task:
Write a program to create an ordered collection ''A'' of functions of a real number. At least one function should be built-in and at least one should be user-defined; try using the sine, cosine, and cubing functions. Fill another collection ''B'' with the inverse of each function in ''A''. Implement function composition as in [[Functional Composition]]. Finally, demonstrate that the result of applying the composition of each function in ''A'' and its inverse in ''B'' to a value, is the original value. <small>(Within the limits of computational accuracy)</small>.
(A solution need not actually call the collections "A" and "B". These names are only used in the preceding paragraph for clarity.)
;Related task:
[[First-class Numbers]]
<br><br>