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.
Hope this is useful to someone. I'd be glad to read any comments.
Robert Dodier