Newsgroups: comp.sys.handhelds
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!rick.cs.ubc.ca!b3300876
From: b3300876@rick.cs.ubc.ca (george chow)
Subject: Summary of 'Good Ways to...'
Message-ID: <1991Apr29.174413.5473@rick.cs.ubc.ca>
Followup-To: comp.sys.handhelds
Sender: news@rick.cs.ubc.ca (Usenet News)
Organization: Rick Lab, CPSC, UBC, Vancouver, B.C., Canada
Date: Mon, 29 Apr 91 17:44:13 GMT

Awhile back I posted two questions about doing things in RPL. I got a bunch of
replies back. Here's a summary. 

Thanks to the following for eithering following up or emailing a response: 
   [1] sjthomas@cup.portal.com
   [2] f89-mda@nada.kth.se
   [3] dcf@zodiac.phy.duke.edu
   [4] rouben@math16.math.umbc.edu
   [5] sburke@jarthur.Claremont.EDU
   [6] @vms3.macc.wisc.edu:KAUFMAN@ETHL.DecNet


There were two suggestions for deletion: 

\<< 
		DUP2 
        1 SWAP 1 - SUB
        3 ROLLD
        1 + OVER SIZE SUB
        +
\>> 

and 

\<< SWAP OBJ\-> DUP DUP 3 + ROLL - 2 + ROLL DROP 1 - \->LIST \>> 

The former (from [4]) is nicer in that range checking is automatic wheras the
latter (from [5]) would crap out. Alas, there seem to be no way to perform a 
deletion efficiently (i.e., in place and with no conversion). 

I received three responses wrt uppercase conversion. They are: 
	[1] rouben@math16.math.umbc.edu
	[2] grue@cs.uq.oz.au
	[3] bson@wheat-chex.ai.mit.edu

[1] provided a version using the NUM and CHR functions. [3] mentioned that it
would not work with different character sets. This was actually was first
attempt and it is slower than the lookup table method. [2] wrote a Saturn
routine for the conversion. The speed improvement is dramatic. So here are the
various versions. 

This was my first attempt (very similar to the one from [1]) that I never posted
but was suggested: 

VNUMCHR 
\<< 
  DUP SIZE 1 SWAP
  FOR i
    DUP i DUP SUB NUM
    IF DUP 96 > OVER 123 < AND THEN
      32 - CHR i SWAP REPL
    ELSE 
      DROP
    END
  NEXT
\>> 

This was the first lookup table method I tried: 

VTABLE1 
\<< 
  DUP SIZE 1 SWAP
  FOR i
    DUP i DUP SUB
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "abcdefghijklmnopqrstuvwxyz"
    ROT POS
    IF DUP THEN
      DUP SUB i SWAP REPL
    ELSE
      DROP2
    END 
  NEXT
\>> 

This was a slightly rearranged lookup table method: 

VTABLE2 
\<< 
  DUP SIZE 1 SWAP
  FOR i
    "abcdefghijklmnopqrstuvwxyz"
    OVER i DUP SUB POS
    IF DUP THEN
      i "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      ROT DUP SUB REPL    
    ELSE
      DROP
    END 
  NEXT
\>> 

This is the Saturn version: (in ASC'd form) 

"D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8
AAE4D71643106AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310E
A6A148161CF8AF2C8F2D760142164808CB2130B2130BDE1" 


I timed the three routines with the following: BM \<< 
  TICKS 1 10
  START
    "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
    <conversion routine>
    DROP
  NEXT
  TICKS - NEG B\->R 8192 /
\>> 

and got the following: 
	VNUMTABLE	29.9 sec 
	VTABLE1		24.0 sec 
	VTABLE2		23.6 sec 
	VML			0.133 sec 

It was pointed out to me that Donneley's Toolkit has Saturn version of both of
these functions. I was aware of that and in fact intend to get that toolkit.
However, I wanted to see how far plain RPL will go. 

Thanks for all the responses. Just FEI, I needed these routine for my own 
address book program. (I know, I know, this is probably the n-th version 
being written for the 48 but I didn't like the ones I've seen...) I'll 
post mine if anyone's interested. (Maybe I'll try out the new 
comp.sys.hp48 group when it becomes official.)

George 

