This is cute, and certainly does some of the
examples in a useful fashion. I think that
the non-interactive mode has to account for
the inability to stop the computation, too.
One way is to have a time limit, e.g.
ev(stuff, maxtime_for_eval=10*CPUSEC) and/or
some space limit
ev(stuff, gclimit_cons_cells= .....)
and there should also be a sandbox version to prohibit,
e.g. exec_shell_command(" rm -r *");
Try
integrate((a*x+b)/(c*x+d),x,r,s);
which asks 5 questions, at least if you answer pos; in
a sequence. My recollection is that you don't really have
3^5 different answers (pos,neg,zero are the choices). You
probably have two distinct ones.
So collapsing the answer takes work.
You don't really want to see stuff like
if a=0 then b else if b=0 then a else a+b.
Making a list of all the places that asksign is used
shouldn't be that hard. Maybe a more reasoned approach
could be made for a multiple-branch version, eventually.
RJF
Robert Dodier wrote:
> hello,
>
> questions about using Maxima as the back end for a
> web interface or some other kind of interface come up
> from time to time, most recently today. aside from
> web interfaces and graphical user interfaces, it seems
> like tools which are at present mostly numerical
> (either spreadsheets like Gnumeric or console i/o
> like Octave or R) could make use of Maxima. also,
> programs which use Lisp or Scheme as an extension
> language could conceivably link into Maxima via the
> extension language.
>
> i believe that a completely noninteractive mode would
> make it much easier to integrate Maxima into other programs
> which want to make use of symbolic computation.
>
> toward this end i've cheesed together some crufty hacks
> which you can see here --
>
> http://maxima.sourceforge.net/wiki/index.php/Noninteractive%20mode
>
> the name of the game (as i see it) is to have asksign and askinteger
> throw something instead of trying to interact with the user.
> then the top-level evaluator constructs a conditional for each
> possible value of the expression asksign / askinteger would have
> asked about.
>
> e.g. integrate (exp(a*x), x, 0, inf) =>
> if a < 0 then - 1/a elseif equal(a, 0) then 0 else merror(Integral
> is divergent)
>
> to make this really workable it would be necessary to plug all
> the holes which lead to user interaction. asksign / askinteger are
> just the biggest ones which come to mind.
>
> i believe it is useful to compute all alternatives instead of
> choosing only one, so this asksign / askinteger replacement
> has substantial value in itself, aside from making it easier to
> plug into other programs.
>
> anyway perhaps this will be interesting to someone.
>
> all the best,
> robert dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima@math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima