Sorry I was a little confused about how to explain this better and I made a mistake. The example should read
(%i1) f(x):= block(if x > 0 then return(void) else return -1)$
(%i2) f(-9);
(%i3) %*9;
(%o3) -9
(%i4) f(9);
(%i5) %*9;
Maxima has encountered a lisp error. Can not operate on nothing.
Rich
----- Original Message -----
From: "Richard Hennessy" <rich.hennessy at verizon.net>
To: "Maxima List" <maxima at math.utexas.edu>
Sent: Sunday, October 04, 2009 9:09 AM
Subject: Void in Maxima
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
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima