ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) (08/23/90)
Date: 08-18-90 (19:19) Number: 3677 (Echo)
To: GORDON GANDERTON Refer#: NONE
From: IAN WATTERS Read: NO
Subj: C OR FORTH Status: PUBLIC MESSAGE
[Sorry about the corruption in this message, but it seems to have been
corrupted before I got a hold of it. -dwp]
GGp3. Write a program that repeatedly calculates how many chars separate
GGptwo letters typed in by the user, until terminated with ctlC. For
GGpinstance there are 2 characters ('b' and 'c') between 'a' and 'd'.
Well, with the BIG warning that I haven't actually tested it...
3 CONSTANT ^C
: Between (S n1 n2 -- n3 ) \ n3 = #integers between n1 & n2
- Abs \ find diffeZe-,YCB Dup IF 1- THEN ; \ if non-
zero, adjust to get right answer
: CBetweener ( -- )
BEGIN
Key Dup ^C <> \ get first key & finish if ^C
WHILE
Key Between \ otherwise get second key & calculate
." " . ." between" CR \ show result and go back for more...
REPEAT
Drop ; \ tidy up stack and finish
Assumes: no wrap around, chr (255)..chr(0)
Ian
PCRelay:IBBSNET -> #143 RelayNet (tm)
NET/Mail : DC Information Exchange, MetroLink Int'l Hub. (202)433-6639
-----
This message came from GEnie via willett through a semi-automated process.
Report problems to: uunet!willett!dwp or dwp@willett.pgh.pa.us