matchdeclare and tellsimpafter is the part where I run into trouble.
The following works well, but doesn't really add anything new:
matchdeclare(any, true);
defrule(derivedtomks,any,letsimp(any,derivedsimpunitrules));
defrule(mkstoderived,any,letsimp(any,derivedexpandunitrules));
defrule(lengthrule,any,letsimp(any,%lengthrules));
defrule(massrule,any,letsimp(any,%massrules));
defrule(timerule,any,letsimp(any,%timerules));
processunits(expression) := block([letrat:true,result1],
apply1(expression,derivedtomks,mkstoderived,lengthrule,
massrule,timerule));
Maxima 5.9.1.1cvs http://maxima.sourceforge.net
Using Lisp SBCL 0.8.20
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) load("ft.mac");
(%o1) ft.mac
(%i2) processunits(kg*m/s^2);
(%o2) N
(%i3) processunits(N*kg*m/s^2);
J kg
(%o3) ----
2
s
(%i4) setunits([cm, grains, minutes, dyne, torr, electron_volt]);
(%o4) done
(%i5) processunits(kg*m/s^2);
(%o5) 100000 dyn
(%i6) processunits(N*kg*m/s^2);
`rat' replaced 6.24150959647704e+18 by 6241509596477042688//1 =
6.24150959647704
e+18
`rat' replaced 15.43235835294143 by 16883//1094 = 15.43235831809872
1097660484555436580224 eV gr
(%o6) ----------------------------
2
41025 %min
but whenever I add tellsimpafter into the mix, things go bad. I can't
seem to figure out the syntax in general, but in addition to that there
are times (like the setunits command, for example) when I don't want
tellsimpafter horning in - I want it to work just before the final
expression is sent to be displayed, and only then. Essentially I want
to duplicate the effect of typing processunits at the command line
automatically. I guess perhaps I'm back to my original suggestion of
adding a new mechanism to do this, or I suppose I could concede defeat
and give up the idea of having it done automatically. Clearly this
can't have been a common need in Maxima.
CY
--- Richard Fateman wrote:
> matchdeclare(r, any);
>
> tellsimp(q(r),qtransformed(foo(r))) ;; if you get the idea.
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo