How to resolve the algorithm Function composition step by step in the PARI/GP programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Function composition step by step in the PARI/GP programming language

Table of Contents

Problem Statement

Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument.

The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x.

Reference: Function composition Hint: In some languages, implementing compose correctly requires creating a closure.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Function composition step by step in the PARI/GP programming language

Source code in the pari/gp programming language

compose(f, g)={
  x -> f(g(x))
};

compose(x->sin(x),x->cos(x)(1)

compose(sin,cos)(1)

  

You may also check:How to resolve the algorithm Hello world/Text step by step in the Miranda programming language
You may also check:How to resolve the algorithm Take notes on the command line step by step in the Ruby programming language
You may also check:How to resolve the algorithm Knapsack problem/0-1 step by step in the Oz programming language
You may also check:How to resolve the algorithm Walk a directory/Recursively step by step in the GUISS programming language
You may also check:How to resolve the algorithm Hex words step by step in the APL programming language