Question: Store values in variable outside of procedure

I have a proc that takes a function. This function is called  when the proc needs it to. Normally it will simply do a computation. The return is generally ignored(since the proc is a bit non-deterministic). I would like, though, to store values computed within the function in a global variable. I can't seem to use assign since it forces the variable to be local.

I can print the result of the function and it shows up but what is the proper way to assign variables within a function:

e.g.,

plot(store(x),x=1..2);

Then store would somehow store the values passed to the function(and in this case probably returning x). The example is not my use case and may not actually work properly.I cannot use global in the function passed as an argument to create a global variable.

F := proc(f)

    blah blah f(3)
    blah blah f(4)

end proc;

R := []:

F(x->store(R, x));

R = [3,4]

Please Wait...