home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.forth.mac
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!news.iastate.edu!bible
- From: bible@iastate.edu (Anthony E Bible)
- Subject: Re: RECURSION?!?
- Message-ID: <BzCyDq.Dyp@news.iastate.edu>
- Sender: news@news.iastate.edu (USENET News System)
- Organization: Iowa State University, Ames, IA
- References: <1992Dec16.052611.3031@peanut>
- Date: Wed, 16 Dec 1992 15:15:24 GMT
- Lines: 19
-
- In article <1992Dec16.052611.3031@peanut> scrogginstom@bvc.edu (Thomas W. Scroggins) writes:
- >I am just starting out using Forth and was wondering if MacForth allows
- >recursion and if anyone has examples if it does.
- >
- >--
-
- Tom:
- Yes it does. Here is an example (factorial -- what else :):
-
- : FACTORIAL ( n1 -- n2) \ return n1 factorial
- ?DUP IF DUP 1- MYSELF * ELSE 1 THEN ;
-
-
- As you can probably tell, MYSELF invokes the word which is being
- compiled, i.e., it recurses.
-
-
- Regards,
- tony
-