Path: utzoo!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!usc!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: Mathematical routines Message-ID: <1714.UUL1.3#5129@willett.pgh.pa.us> Date: 12 Sep 90 03:26:37 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 32 Date: 09-10-90 (10:19) Number: 3746 (Echo) To: ALL Refer#: NONE From: CHARLIE HITSELBERGER Read: (N/A) Subj: IS THIS COMMONLY DONE? Status: PUBLIC MESSAGE I recently had to write some code to roll dice in Forth, and here is what I wound up with. My question is, is the " 0 BEGIN DROP " a commonly used thing for loops that leave a value on the stack upon exit? CODE RANDU ( -- rnd ; leaves a random number 0-255 on the stack ) ... machine specific stuff to generate a random byte ... ENDCODE : DICE ( -- n1 n2 ) 2 0 DO 0 BEGIN DROP RANDU 7 AND DUP 6 < UNTIL 1+ LOOP ; Just wondering, that's all. ----- This message came from GEnie via willett through a semi-automated process. Report problems to: uunet!willett!dwp or dwp@willett.pgh.pa.us