optional arguments



On Wed, 2005-30-11 at 11:19 -0800, Richard Fateman wrote:
>  Try
> foo([a]):=  a[1]+a[2];
> foo(3,4);  -> 7
> foo(3,4,5); -> still 7.
> 
> you get the idea?
> 
> There are other issues about what to do if you don't
> want to evaluate the arguments, as might be the case
> for plotting.

This is, of course my goal ;-)

Thanks Richard and Chris, I have managed to produce the behaviour I am
looking for but am wondering whether this could have been done in a more
efficient manner:

polarplot(expr,range,[xyrange]) := 
block([theta_var:range[1]], set_plot_option([nticks,500]), 

if (length(xyrange)=0) then 
(
set_plot_option([gnuplot_preamble,"set key off; set size ratio -1"]), 
plot2d(['parametric, cos(theta_var)*expr, sin(theta_var)*expr, range])) 

else (if (length(xyrange)=1) then 
(xrange:xyrange[1], 
plot2d( ['parametric, cos(theta_var)*expr, sin(theta_var)*expr, range],
xrange, [gnuplot_preamble,"set key off; set size ratio -1"]))

else

(xrange:xyrange[1], yrange:xyrange[2], 
plot2d( ['parametric, cos(theta_var)*expr, sin(theta_var)*expr, range],
xrange, yrange, [gnuplot_preamble,"set key off; set size ratio -1"]))
) 

)$

Thanks, Bob
-- 
Dr. Robert J. Jerrard, Professor of Mathematics,
Concordia University College of Alberta,
7128 Ada Blvd., Edmonton, Alberta, T5B 4E4, Canada.
Phone: (780) 479-9291, Fax: (780) 474-1933.
-- 
Dr. Robert J. Jerrard, Professor of Mathematics,
Concordia University College of Alberta,
7128 Ada Blvd., Edmonton, Alberta, T5B 4E4, Canada.
Phone: (780) 479-9291, Fax: (780) 474-1933.