Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #27162

Re: Double multiplication

From "Rod Pemberton" <dont_use_email@xnohavenotit.cnm>
Newsgroups comp.lang.forth
Subject Re: Double multiplication
Date 2013-12-05 21:24 -0500
Organization Aioe.org NNTP Server
Message-ID <op.w7nfmyxb5zc71u@localhost> (permalink)
References <l72gu7$qj0$1@odin.sdf-eu.org> <ac654e44-0900-4f97-8ae2-5efb52883c32@googlegroups.com> <l7fasa$4ih$1@speranza.aioe.org> <b853368b-f694-4e9c-8560-b197f7252132@googlegroups.com> <52a06e37$0$2919$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


On Thu, 05 Dec 2013 07:14:43 -0500, Hans Bezemer  
<the.beez.speaks@gmail.com> wrote:
> mhx@iae.nl wrote:
>> On Sunday, December 1, 2013 8:41:55 PM UTC+8, Ed wrote:

>>> Conventionally these would be:
>>> 2TUCK ( x1 x2 x3 x4 -- x3 x4 x1 x2 x3 x4 )
>>> 2NIP ( x1 x2 x3 x4 -- x3 x4 )
>>> as they work equally well with pairs of singles.
>>
>> Actually, I never use DTUCK (too deep for comforth).
>> DNIP is because I have seen 2NIP ( x2 x1 x0 -- x1 x0 ).
>
> 2TUCK is done with 9 instructions:
>
> : 2tuck over >r rot >r rot over r> r> rot ;
>
> You won't define 2OVER so easily with these basic instructions.
>

These were found using a modified version of Peter
Sovietov's Forth Wizard.

: r@ r> dup >r ;
: rot >r swap r> swap ;
: -rot swap >r swap r> ;
: nip swap drop ;
: tuck dup >r swap r> ;
: over >r dup r> swap ;

: 2drop drop drop ;
: 2>r swap >r >r ;
: 2r> r> r> swap ;
: 2r@ r> r> dup >r swap dup >r ;
: 2nip >r >r drop drop r> r> ;
: 2dup >r dup r> dup >r swap r> ;
: 2swap >r swap r> swap >r >r swap r> swap r> ;
: 2tuck over >r rot >r rot over r> r> rot ;
: 2over >r >r over over r> r> rot >r rot r> ;
: 2rot >r >r 2swap r> r> 2swap ;
: -2rot 2swap >r >r 2swap r> r> ;

2tuck 2over 2rot -2rot were taking up too much time
finding solutions without rot over 2swap.  I expect
most of them to expand to around 20 or more.  Coos'
solution for 2tuck without rot is at 18 using over.


Rod Pemberton

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Double multiplication David Meyer <papa@sdf.org> - 2013-11-26 16:06 +0000
  Re: Double multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-11-26 16:13 +0000
    Re: Double multiplication "Alex McDonald" <blog@rivadpm.com> - 2013-11-26 22:59 +0000
    Re: Double multiplication Hans Bezemer <the.beez.speaks@gmail.com> - 2013-11-27 22:34 +0100
      Re: Double multiplication anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-11-28 15:51 +0000
  Re: Double multiplication mhx@iae.nl - 2013-11-26 10:14 -0800
    Re: Double multiplication "Ed" <invalid@invalid.com> - 2013-12-01 23:41 +1100
      Re: Double multiplication mhx@iae.nl - 2013-12-02 02:23 -0800
        Re: Double multiplication "Ed" <invalid@invalid.com> - 2013-12-05 22:19 +1100
        Re: Double multiplication Hans Bezemer <the.beez.speaks@gmail.com> - 2013-12-05 13:14 +0100
          Re: Double multiplication Coos Haak <chforth@hccnet.nl> - 2013-12-06 00:16 +0100
          Re: Double multiplication "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2013-12-05 21:24 -0500
  Re: Double multiplication albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-11-26 20:20 +0000
    Re: Double multiplication "Elizabeth D. Rather" <erather@forth.com> - 2013-11-26 11:43 -1000

csiph-web