how to apply a list of functions (or commands) to a list of data

lohabithi shared this question 1 year ago
Answered

I am trying to implement an algorithm that has 3 functions running in parallel, each step depending on the previous state of the 3 functions together.

I can implement it manually by creating a tool having these 3 functions inside, and then by clicking on the tool and inputs as many times as iterations I want (or by typing it).

But I want this process to be done automatically, without clicking (which can generate errors, and take time).

It is possible to place functions in a list:

f(a,b)=a+b

g(a,b)=a-2b

h(a,b)=2a+3b

flist={f,g,h}

and then it is possible to do:

function=flist(2)

function(3,2)

-1

but I am not able to do:

flist(2) (3,2)

I am also not able to use zip.

Is there a turnaround?

Best Answer
photo

try zip(w(3,2),w,flist)

I advice you to use function (x,y)

Comments (3)

photo
1

Hi lohabithi!

Does this command work for you?

I think it is only available in CAS.


Substitute(Element(flist, 2), {a,b}, {3,2})

Kind regards

mire2

photo
1

try zip(w(3,2),w,flist)

I advice you to use function (x,y)

photo
1

mathmagic: That is truly beautiful! Thank you.

© 2019 International GeoGebra Institute