First-class functions: Difference between revisions

Content deleted Content added
m added whitespace.
m added whitespace before the TOC, added a Task and C.f. (bold) headers.
Line 6: Line 6:
* Use functions as arguments to other functions
* Use functions as arguments to other functions
* Use functions as return values of other functions
* Use functions as return values of other functions



<br>
<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>.
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.)
(A solution need not actually call the collections "A" and "B". These names are only used in the preceding paragraph for clarity.)


;C.f.
C.f. [[First-class Numbers]]
[[First-class Numbers]]
<br><br>


=={{header|ActionScript}}==
=={{header|ActionScript}}==