On Mon, 2004-08-02 at 13:19, Luis Alejandro Marquez Martinez wrote:
> Thanks everyone for your help. This simple script from Starvos Macrakis
> did the job:
>
> stripped_tex(expr):=
> block([str: tex(expr,false)],
> concat("",?subseq(str,2,?length(str)-2)))$
>
<snip>
> * I agree need to learn lisp (Yet Another Lisp Virgin!). However, it
> seems a bit tricky to use it within maxima. I tried the following command:
I would have written the stripped_tex function as a pure Lisp function.
In that way you would avoid the ugliness that follows. However, I have
to confess that I do not know how to call defmspec'd functions such as
"tex" off the top of my head, so I can't give you a simple example right
now.
> marquez@pc-lmarquez:~> clisp
> (clisp header suppressed)
> [1]> (string-trim " ($)" "$$x^2$$");
> "x^2"
>
> so this is legal lisp (at least for clisp, the lisp I am using with
> maxima). However from maxima it does not work. I tried some variations
> based on a hint from Richard Fateman
> ?string-trim(" ($)" "$$x^2$$");
> ?string\-trim(" ($)" "$$x^2$$" );
> ?string\-trim(" ($)", "$$x^2$$" );
> but they all ended with error messages! What is the correct way to
> "translate" this function?
There are three issues here:
1) string-trim needs quoting because "-" is not a legal character for a
Maxima function.
2) Maxima argument lists are separated with commas instead of spaces.
Your last attempt addressed (1) and (2).
3) Maxima does not have strings. Things in double quotes get converted
to symbols. This is probably a little known fact. It may even change in
the future. In the meantime, here is the answer to your question:
|abacus3>rmaxima
Maxima 5.9.0.9beta2 http://maxima.sourceforge.net
Using Lisp CMU Common Lisp 18e fedora release 0.fdr.2.e.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) ?string\-trim(?string(" ($)"), ?string("$$x^2$$"));
(%o1) x^2
(%i2) quit();
--Jim