Originally Posted by

**paskari** That's strange, it worked for me as well, to a certain degree

But there is some strange behaviour associated with 'proc'. For example if you type in the following

>y:=2;

>parabola:=proc(x)

global y;

print("x is",x);

x^y;

end;

>plot(parabola,-5..5);

I'm expecting something like

x is -5

x is -4

x is -3

...

but instead I get much more than the 11 calls to the function, and it's in the form of

x is -4.972378378373...

x is -4.596886676334...

x is-4.3234324234323...

This is a problem if the procedure has any side effects, like if a global variable is being updated.

I think what's happening is that the plot function keeps calling the procedure to increase the accuracy of the graph, but with sheer disregard for side effects.

Try this:

Code:

> y := 2:
> parabola := proc( x :: integer ) # x can only be
# an integer.
global y;
print("x is", x," and ", x ," to the ", y," is ",x^y);
end:
> seq(parabola(x),x=-5..5);

and see if this is what you want!

--Chris