Re: sexaguesimal



--- Robert Dodier  wrote:

> Makes sense to me. As it stands, the easy part is the
> input parsing -- e.g.
> 
>   matchfix ("%60", "@")$ matchfix ("@", "%60")$
>   %60 [L] @ := block ([n: length (L)], m: makelist (60^(n-i-1), i, 0,
> n-1), apply ("+", m*L));
>   @ [L] %60 := block ([n: length (L)], m: makelist (1/60^i, i, 1, n),
> apply ("+", m*L));
> 
>   %60 7,20,11 @ + @ 11,20,7 %60;  ==>  5704816807/216000
> 
> However, I don't know how to get 5704816807/216000 displayed
> in base 60 notation without an explicit function call.
> It seems like what we want here is a new type of object,
> which carries the base and list of digits around with it,
> and it gets displayed appropriately. Creating a new object
> type is easy enough, but how to hook into the display code?

Perhaps something along the lines of what Dr. Willis showed me how to
do for the unit package would help (it turns out tellsimpafter can be
used to run a function on the output, but it's a bit non-obvious, at
least to me)

matchdeclare(a,covertabletobasesixty(a),b,notconvertabletobasesixty(b));
tellsimpafter(a*b),a*displaybasesixty(b));
 
I don't know how that would be tweaked (it's a use of tellsimpafter I
still don't fully understand) but it might be used to do base sixty
display somehow or other - it is what will allow me to do things like
kg*m/s^2 -> Newton without requiring a user input a specific function.

> The other part that I haven't addressed here is how to
> get base-60 objects to interact with ordinary integers
> or rationals. Maybe tellsimp? I'm just guessing here.

You might try variations of the above.  What I would try is converting
everything to normal base, doing an ev to get it to handle
calculations, and then convert back to the desired base once you are
done - define function(s) to do that, then using a variation of the
above add it to the tellsimp rules.

(Incidently, I'd like to publicly thank Dr. Barton Willis for some
awesome help on (re)designing a proper units package.  I've got a ways
to go on the coding, but he has found ways to handle various operations
in Maxima that are both powerful and elegant and solved pretty much all
of my roadblock problems.  Without him this thing would still be at the
dock or at the level of the old one in share/contrib.  Given time,luck
and Real Life staying out of my hair for a little while, the current
list of definitions that constitutes our unit package will be updated
with something much more interesting.  OK, teaser over - as you were
;-)  

CY


	
		
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/