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


Groups > comp.lang.forth > #26102

Y combinator

Newsgroups comp.lang.forth
Subject Y combinator
References <a4aljf$2q2$1@news.tuwien.ac.at>
From Lars Brinkhoff <lars.spam@nocrew.org>
Organization nocrew
Date 2013-10-03 09:57 +0200
Message-ID <85eh82hjlr.fsf@junk.nocrew.org> (permalink)

Show all headers | View raw


> Defining Y in ANS Forth (no RECURSIVE) is left as an exercise to the
> reader:-)

I read, I exercised, I posted.

: y ( xt1 -- xt2 )   here tuck 2>r  1 cells allot
   :noname r> postpone literal postpone @ r> compile, postpone ;
   dup rot ! ;

\ Sample usage, factorial function:
:noname ( u1 xt -- u2 )   over ?dup if 1- swap execute * else 2drop 1 then ;
y 6 swap execute .

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


Thread

Y combinator Lars Brinkhoff <lars.spam@nocrew.org> - 2013-10-03 09:57 +0200
  Re: Y combinator anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-03 13:09 +0000
    Re: Y combinator Lars Brinkhoff <lars.spam@nocrew.org> - 2013-10-07 15:06 +0200

csiph-web