Re: [stack] Re: Programming Puzzle
"Christopher Diggins" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Very nice! I particularly like the use of intelligible names, something I too often fail to do. Unless, I am mistaken I believe "dup i" or "recurse" is the classical Y combinator. Notice the second occurence of "dup i" hidden in the definition of "make-recursive", which makes sense given the name. ;-) I am going to have to throw some harder puzzles at this gang ;-) - Christopher On 5/16/07, Ivan Tomac <[email protected]> wrote: > > --- In [email protected] <concatenative%40yahoogroups.com>, > "Christopher Diggins" > <cdiggins@...> wrote: > > 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" > > > > LIBRA > > (* Joy doesn't appear to have unit and cat combinators - unit == [] cons > ? *) > > unit == [] cons ; > cat == concat ; > > (* first thing's first - define cons *) > > cons == [unit] dip cat ; > > make-recursive == [dip dup i] cons ; > fix-predicate == [dip swap ] cons ; > > construct-loop == [[pop] ifte] cons cons ; > > recurse == dup i ; > > while == [fix-predicate] dip make-recursive construct-loop recurse . > > 10 [0 >] [dup put 1 -] while . > > > Cheers, > > Christopher > > > > Ivan > > [Non-text portions of this message have been removed] > > > [Non-text portions of this message have been removed]