How to resolve the algorithm First-class functions step by step in the Maxima programming language
How to resolve the algorithm First-class functions step by step in the Maxima programming language
Table of Contents
Problem Statement
A language has first-class functions if it can do each of the following without recursively invoking a compiler or interpreter or otherwise metaprogramming:
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. (Within the limits of computational accuracy). (A solution need not actually call the collections "A" and "B". These names are only used in the preceding paragraph for clarity.)
First-class Numbers
Let's start with the solution:
Step by Step solution about How to resolve the algorithm First-class functions step by step in the Maxima programming language
Source code in the maxima programming language
a: [sin, cos, lambda([x], x^3)]$
b: [asin, acos, lambda([x], x^(1/3))]$
compose(f, g) := buildq([f, g], lambda([x], f(g(x))))$
map(lambda([fun], fun(x)), map(compose, a, b));
[x, x, x]
You may also check:How to resolve the algorithm Date format step by step in the Crystal programming language
You may also check:How to resolve the algorithm Pascal's triangle/Puzzle step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Pi step by step in the F# programming language
You may also check:How to resolve the algorithm Benford's law step by step in the VBA (Visual Basic for Application) programming language
You may also check:How to resolve the algorithm Damm algorithm step by step in the Draco programming language