Maxima as a scripting language, was: embedding maxima in a CGI script



Hello Ben,

This is going off on a bit of a tangent, but: it seems feasible to use
Maxima as a scripting language itself instead of calling it from a
script written in another language. The goal would be to cut out
one layer of stuff when writing a Maxima-based web app.

Here is something I made up to play with this idea.
Block-structured web pages are a lot like expressions!

 a: a[href="http://maxima.sf.net";]("Maxima home page");
 p1: p("You can go to", a, "if you like.");
 p2: p("Lots of cool stuff there.");
 b: body (p1, p2);
 h1: head (title ("Maxima rocks"));
 h2: html (h1, b);
 s: mxm2xml (h2);
 block ([linel: 1000], print(s))$  =>

Maxima rocks

 

You can go to Maxima">http://maxima.sf.net">Maxima home page if you like.

Lots of cool stuff there.

Here is the code for mxm2xml. NL: " "; mxm2xml([e]) := if length(e) = 1 then (e: e[1], if atom(e) then e else block([o : op(e), a: apply (concat, separate (map (mxm2xml, args(e))))], if atom(o) then concat ("<", o, ">", a, "", NL) else concat ("<", op(o), " ", apply (concat, separate (map (string, args(o)))), ">", a, "", NL))) else apply (concat, map (mxm2xml, e)); separate(L) := if not listp(L) or length(L) < 2 then L else block ([r: rest(L), n], n: length(r), cons (first(L), join (makelist (" ", i, 1, n), r))); Maxima probably doesn't have enough string, stream, and file functions built in, but that stuff would be easy to add, and in any case one can always drop into Lisp to do that stuff. Food for thought, Robert Dodier