Re: [stack] Programming Puzzle

"Joshua Shinavier" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Well, this seems to work:

DEFINE mywhile ==
    swap [dup] dip swap
    [[dup dip] dip mywhile] cons cons
    []
    ifte.

E.g.

1 [2 *] [dup 100 <] mywhile.

yields 128.  However, it uses cons, which is not in your list.  I think I
should be able to construct cons like so:

DEFINE cons == [unit] dip concat.

...if only knew how to construct unit :-)

Josh


On 5/16/07, Christopher Diggins <[email protected]> wrote:
>
>   For your amusement here is a fun programming puzzle:
>
> Define a while loop that takes a loop body and termination predicate
> in Joy using only the following combinators:
>
> "ifte","cat","swap","dup","pop","i","dip" and "unit"
>
> Cheers,
> Christopher
>  
>


[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.