Hello,
Here is a sketch of Maxima code for working with base 60 arithmetic.
This stuff assumes tellsimpafter has been patched in some way to
fix the problem with "+" operands that satisfy the same predicate.
matchfix (">>", "<<");
b60p (expr) := if atom(expr) then false
else nounify(op(expr)) = nounify(">>");
nzi (x) := integerp (x) and x # 0; /* "nonzero integer" */
matchdeclare ([uu, vv], b60p);
matchdeclare (ii, nzi);
/* Here's the fun part! */
simp: false;
tellsimpafter (uu + ii, b60\+int (uu, ii));
tellsimpafter (uu + vv, b60\+b60 (uu, vv));
tellsimpafter (-1*uu, \-b60(uu));
simp: true;
/* Some objects to work with */
a: >> 23, 7, 5 <<;
b: >> 11, 43, 17 <<;
/* These operations yield noun forms of b60\+int, etc.
but at this point we just want to verify that the
simplification rules have been invoked. */
a + 123; /* yields b60+int(>>23, 7, 5<<, 123) */
b + 39243; /* yields b60+int(>>11, 43, 17<<, 39243) */
a + b; /* yields b60+b60(>>23, 7, 5<<, >>11, 43, 17<<) */
a - b; /* yields -b60(>>11, 43, 17<<) + >>23, 7, 5<< */
/* Imagine hackish definitions here. */
b60\+int (a, i) := block (...);
b60\+b60 (a, b) := block (...);
\-b60 (a) := block (...);
/* Now redo the operations. */
a + 123; /* yields >>26, 9, 5<< */
b + 39243; /* yields >>14, 37, 28<< */
a + b; /* yields >>34, 50, 22<< */
a - b; /* yields >>12, - 36, - 12<< */
Fun! The >> << notation is pretty clumsy, other operations
aren't covered here, fractions aren't covered, and the
numerical results shown are probably wrong. But perhaps
it's a start.
For what it's worth,
Robert Dodier
__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/