home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / forth / mac / 32 < prev    next >
Encoding:
Text File  |  1992-12-16  |  908 b   |  31 lines

  1. Newsgroups: comp.lang.forth.mac
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!news.iastate.edu!bible
  3. From: bible@iastate.edu (Anthony E Bible)
  4. Subject: Re: RECURSION?!?
  5. Message-ID: <BzCyDq.Dyp@news.iastate.edu>
  6. Sender: news@news.iastate.edu (USENET News System)
  7. Organization: Iowa State University, Ames, IA
  8. References: <1992Dec16.052611.3031@peanut>
  9. Date: Wed, 16 Dec 1992 15:15:24 GMT
  10. Lines: 19
  11.  
  12. In article <1992Dec16.052611.3031@peanut> scrogginstom@bvc.edu (Thomas W. Scroggins) writes:
  13. >I am just starting out using Forth and was wondering if MacForth allows
  14. >recursion and if anyone has examples if it does.
  15. >
  16. >-- 
  17.  
  18. Tom:
  19.     Yes it does.  Here is an example (factorial -- what else :):
  20.  
  21. : FACTORIAL  ( n1 -- n2)    \ return n1 factorial
  22.    ?DUP IF  DUP 1-  MYSELF *  ELSE  1  THEN ;
  23.  
  24.  
  25.     As you can probably tell, MYSELF invokes the word which is being
  26. compiled, i.e., it recurses.
  27.  
  28.  
  29. Regards,
  30. tony
  31.