Re: [stack] Programming Puzzle

"Christopher Diggins" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Well done!

I made a mistake with my Joy words: "cat" is supposed to be "concat".

I did include "unit" in my list, so the construction is valid according to
the rules I set out.
I also believe in Joy you can define unit as "[] concat", am I correct?

Second puzzle: do the same without using the name of the function in the
definition.

Does any know of smaller constructions?

- Christopher


On 5/16/07, Joshua Shinavier <[email protected]> wrote:
>
>   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] <cdiggins%40gmail.com>>
> 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]
>
> 
>


[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.