Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Rod Pemberton Newsgroups: comp.lang.forth Subject: Re: Stack Operator Symbols Date: Sat, 29 Oct 2016 18:46:35 -0400 Organization: Aioe.org NNTP Server Lines: 41 Message-ID: <20161029184635.4cd709eb@_> References: <4e481228-bd80-4e39-a629-90a690e50756@googlegroups.com> <20161027191345.4f524e44@_> <-Lmdneii--uHXI_FnZ2dnUU7-VnNnZ2d@supernews.com> <87d1ijmwc3.fsf@nightsong.com> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Newsreader: Claws Mail 3.13.1 (GTK+ 2.24.13; x86_64-unknown-linux-gnu) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:52296 On Sat, 29 Oct 2016 00:46:20 -0700 Paul Rubin wrote: > "Elizabeth D. Rather" writes: > > I wrote Forth professionally for 30 years without using PICK, ROLL, > > or -ROLL, suffering zero inconvenience. > > I needed a 3DUP word recently, and wrote something like: > > : 3dup ( a b c -- a b c a b c ) >r 2dup r@ -rot r> ; > > Later I saw someone else's implementation: > > : 3dup ( a b c -- a b c a b c ) 2 pick 2 pick 2 pick ; > > which I thought was much more symmetric and natural. Of course for > non-purists, > > : 3dup { a b c } a b c a b c ; > > is the simplest of all. Alex McDonald has a solver based on code from Anton Ertl, IIRC. I also have another based on Java code by Peter Sovietov. So, there are many ways to implement 3DUP depending on what Forth words you want to use. Here are a few: : 3DUP DUP >R SWAP DUP >R SWAP >R >R DUP R> SWAP R> SWAP R> R> ; : 3DUP OVER >R >R OVER R> SWAP OVER R> SWAP ; : 3DUP >R OVER OVER R@ -ROT R> ; : 3DUP >R NUP TUCK R@ -ROT R> ; : 3DUP >R 2DUP R@ -ROT R> ; : 3DUP >R R@ R> 2OVER ROT ; : 3DUP DUP 2SWAP 2TUCK ROT ; : 3DUP DUP 2OVER ROT ; Rod Pemberton