Robert Dodier wrote:
> Hello,
>
> inspired by a recent question about carpentry, I've committed some
> new stuff in ezunits. As before foo ` bar `` baz changes units bar
> to units baz. Now if baz is a list, the result is a list in which
> quantities are integers except for the last.
>
> load (ezunits);
>
> 86401 ` s `` [hour, minute, s];
> => [24 ` hour, 0 ` minute, 1 ` s]
>
> 10^7 ` m^2 `` [mile^2, acre, foot^2, inch^2];
> => [3 ` mile^2, 551 ` acre, 2344 ` foot^2, 388096/16129 ` inch^2]
>
> map (lambda ([x], x `` m^2), %);
> => [121405692672/15625 ` m^2, 174204522558/78125 ` m^2,
> 85064346/390625 ` m^2, 6064/390625 ` m^2]
>
> apply ("+", %);
> => 10000000 ` m^2
>
> x ` m `` [yard, foot, inch];
> => [floor(1250*x/1143) ` yard,
> floor(3*(1250*x/1143-floor(1250*x/1143))) ` foot,
> 12*(3*(1250*x/1143-floor(1250*x/1143))
> -floor(3*(1250*x/1143-floor(1250*x/1143)))) ` inch]
>
> ev (%, x = 500);
> => [546 ` yard, 2 ` foot, 640/127 ` inch]
>
> I thought about making the result something like x ` hour
> + y ` minute + z ` s but Maxima reorders operands of "+".
> I guess I could invent a noncommutative plus operator.
>
Fun but I prefer not to mess with the syntax; my fear of such changes is
possible problems from front ends' displays, and also interference from
other syntax changes.
convert_units(number,old_units, new_units) could handle
convert_units(60,sec,[hours,minutes])
Maple and Mathematica have commands that push expressions in certain
directions that are sort of analogous.
e.g. pushing asin toward log, or cos towards complex exponential ...
convert(expression, [exp]). or
simplify(expression, [exp]).
These are not units, of course.
RJF