[Maxima] Void in Maxima

Richard Hennessy rich.hennessy at verizon.net
Sun Oct 4 08:09:35 CDT 2009


Is there a way to cause a function to have no return value.  I would like to have the ability to have no return value like you can 
do in C++ with the void keyword.  I tried

f(x) := block(return());

but that returns false which is not the same as no return value at all.  Also this would have to be conditional too.

So

f(x):= block(if x > 0 then return(void) else return -1);

It would be nice and necessary also that no output label would be created if the function returns nothing.  So in this case if f(9) 
would get an output label created but f(-9) would get no output label.  All operations attempting to operate on the return value of 
nothing would also cause a lisp error.


(%I1)  f(x):= block(if x > 0 then return(void) else return -1)$
(%i2) f(9);
(%i3) %*9;
(%o3) 81
(%i4) f(-9);
(%i5) %*9;
Maxima has encountered a lisp error.  Can not operate on nothing.

Is there a way to do this?

Rich





More information about the Maxima mailing list