Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hp-pcd!hpcvra!billw From: billw@hpcvra.CV.HP.COM (William C Wickes) Newsgroups: comp.sys.handhelds Subject: Re: Generalized unit conversion on the HP48sx Message-ID: <25590040@hpcvra.CV.HP.COM> Date: 2 Aug 90 23:57:34 GMT References: <6340@helios.ee.lbl.gov> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 30 The program listed below converts a unit object into a list, where the first element of the list is the unit magnitude, and the remaining elements are the powers of the base units represented in the unit object, in the order { kg m s A K cd mol }. This is still not an elegant solution to Mr. Austern's problem, but it might be a little less disgusting. %%HP: T(3)A(R)F(.); \<< 1 1 1 1 1 1 1 \-> kg m s A K cd mol @Make local variables \<< OBJ\-> UBASE \->STR @Convert normalized unit ob to string 4 OVER SIZE SUB @Strip off "'1_" "'" SWAP + OBJ\-> @Convert to an expression \<< @Start of subroutine prog { kg m s A K cd mol } SWAP GET @Get the ith base unit 10 OVER STO @Assign it value 10 OVER EVAL LOG @Get the power of the base unit 1 ROT STO @Restore value 1 \>> @End of subroutine prog { } \-> prog list @Store prog, and an empty list \<< 1 7 @For each base unit: FOR i i prog EVAL @Get the power 'list' SWAP STO+ @Add the power to the list NEXT DROP @Discard the expression list @Retrieve the list + @Add the unit magnitude at the head \>> \>> \>>