NValsted

5 Reputation

One Badge

7 years, 219 days

MaplePrimes Activity


These are questions asked by NValsted

Hey everyone
 

I am trying to create a procedure, which includes a part, where a function is plotted. I want to be able to declare the range of the plot within the procedure parameters as x=range - example when executing: procedureName(function,x=range). I have isolated a small part of the procedure and the different approaches I have tried:

For simplicity's sake let's call the procedure test.

test:=proc(function,{x::range:=0..1})

#I would then like to be able to plot the following:

plot(function,'x'=x);

end proc:
 

However, the single quotes do not prevent x from being evaluated within the procedure, and there interprets the second argument of 'plot' as 0..1=0..1. Another approach I tried was the following:

 

test:=proc(function,{x::range:=0..1})

local xRange:=x;

unassign('x');

plot(function,x=xRange);

end proc:

 

However, I run into the same problem as above - the elements within the single quotes are still evaluted within the procedure. A workaround would be to simply rename the range parameter, for example:

 

test:=proc(function,{xInr::range:=0..1})

plot(function,x=xInr);

end proc:

 

I would really like to be able use x as the parameter, though.

 

Thanks in advance!

Page 1 of 1