Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #43767
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Defining iteration using recursion |
| Date | 2015-11-25 17:59 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n34suk$83a$1@dont-email.me> (permalink) |
| References | <078dcbab-913c-448b-b617-400c25137388@googlegroups.com> <510521f3$0$294$14726298@news.sunsite.dk> <kgoh0d01hie@enews2.newsguy.com> <meo8ch$onn$1@dont-email.me> |
WJ wrote: > > Doug Hoffman wrote: > > > > > You could do this: > > > > > > : hi ." Hello World!" .s cr ; > > > > > > : times' ( xt n -- ) \ execute word xt Usage: ' <word> 5 times > > > ?dup 0> > > > if 1- swap tuck execute > > > recurse else drop > > > then > > > ; > > > > > > : times ( n -- ) > > > \ input stream: <name> > > > ' swap times' ; > > > > > > 5 times hi > > > > > > -Doug Ocaml: let hi () = print_endline "Hello, world!" ;; let rec times n myfunc = if n>0 then (myfunc (); times (n-1) myfunc) else () ;; times 5 hi;; Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! - : unit = () -- The report card by the American Society of Civil Engineers showed the national infrastructure a single grade above failure, a step from declining to the point where everyday things simply stop working the way people expect them to. --- washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html
Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread
Re: Defining iteration using recursion "WJ" <w_a_x_man@yahoo.com> - 2015-11-25 17:59 +0000
csiph-web