Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!snorkelwacker.mit.edu!ai-lab!rice-chex!bson From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.handhelds Subject: Re: DEC2FRAC-II for the HP48SX Message-ID: <14393@life.ai.mit.edu> Date: 27 Mar 91 20:51:18 GMT References: <27efcf56:1772.1comp.sys.handhelds;1@hpcvbbs.UUCP> <40605@cup.portal.com> <1991Mar27.125528.7914@en.ecn.purdue.edu> Sender: news@ai.mit.edu Organization: nil Lines: 37 In a posting of [27 Mar 91 12:55:28 GMT] wscott@en.ecn.purdue.edu (Wayne H Scott) writes: > 2: '.5*X-.75' > 1: 10 > DEC2FRAC <-- ->Q works this way but I don't know how > 1: '1/2*X-3/4' to duplicate it. The following program used ->Q instead of DEC2FRAC (only for illustrative purposes, I don't have DEC2FRAC at hand): DO->Q: << IFERR OBJ-> @ Break up algebraic -> n oper @ Save operand count and operator (e.g. +) << 1 n START @ Loop operands DO->Q @ Convert operand n ROLL @ Move to next operand circularly NEXT oper EVAL @ Join back together >> THEN ->Q END @ Not algebraic - apply your ->Q here >> Thus, '(.5+.2)/.1' DO->Q results in '(1/2+1/5)/(1/10)' Limitations are of course arguments made up of lists, programs, strings, etc, that are acceptable to OBJ->. The IFERR construct can be replaced by a rather extensive type check, much easier done with system RPL. I didn't keep Joe's DEC2FRAC (assuming I can get it from your server whenever I need it), but the code above should be fairly trivial to adapt to it. (So we'll leave that as a reader exercise.) -- Jan Brittenson bson@ai.mit.edu