--- Peter Scott wrote:
> I wrote a function which binds print2d to false and uses
> WITH-OUTPUT-TO-STRING to return a 1D pretty-printed version of Maxima
> expressions. Am I duplicating effort? Is there some function similar
> to DISPLA which takes a stream argument, for example?
To get a 1-d Maxima string: (setq s (meval '(($string) $foo)))
To output to a stream: (displaf $foo stream)
(like displa, but to a stream)
To output to a file: (meval '(($stringout) &filename $foo))
$stringout seems to be suffering from unintended case-inversion.
Maybe you should use displaf til $stringout is fixed.
An aside on strings: Maxima strings are actually symbols,
which begin with an ampersand. If you want a Lisp string
you'll have to munge it. Dunno if there's a built-in to do that.
> What I would really like to do is interpolate Lisp values into Maxima
> expressions. I'll give you a concrete example:
[...]
> In both cases, I was just taking the output from the '#$ ... $ trick
> above, downcasing it, and using backquoting to interpolate my own
> values before Maxima simplifies it. This is not pleasant to code or
> to read.
About making the coding less painful -- there are macros
m+, m-, m*, m//, and m^ to carry out addition, subtraction,
multiplication, division, and exponentiation, which return a
number if the operands evaluate to numbers and an expression
otherwise. So instead of writing '((mplus simp) $foo $bar)
one could write (m+ '$foo '$bar). So I think
`((mtimes simp) ((mexpt simp) ,(x-component (velocity body)) -1)
((mplus simp)
((mtimes simp) -1 ,(point-x (initial-coordinates body))) ,x))
could be replaced by something like
(m* (m// 1 (x-component (velocity body)))
(m- (point-x (initial-coordinates body))) x))
(Hmm, I guess (m* (m// 1 ...) ...) can be collapsed into (m// ...
...)).
About interpolating values into expressions, how about this:
#$ make_mess (a, b) := cos(a) + b*%pi / (b-a)^7 $
(let ((x1 whatever1) (x2 whatever2) (my-mess))
(setq my-mess (meval (list '($make_mess) x1 x2))))
Anyway these are just some random ideas. Hope this helps,
and I wouldn't be surprised if there are much better ways
to do any or all of this.
regards,
Robert Dodier
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail