Re: [stack] Code Transformation Problem (possibly monadic?)

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Christopher Diggins <[email protected]> wrote:
> William Tanksley, Jr <[email protected]> wrote:
> > I think I have an answer.

> > Let T be your transform. T(m) = dup [m] dip; T([m]) = dup [m] cons;
> > T(x) = [x] dip; T([x]) = [x] swap. Finally, the top-of-stack must be
> > dropped at the end of the transformed sequence.

> I really appreciate your help here. I have not yet convinced myself
> that this generalizes to dynamically constructed quotations but it
> looks really really close. I will try to come up with a set of
> examples and tests.

The tough part should be the flattening algorithm, of course. I didn't
test it at all, I merely typed it in after some thought and a few
minutes, so I may have missed some special case. I certainly didn't
make it easy to implement.

I also can't tell you whether T has the semantics you want :-). But it
should have the effect of passing a single constant value to every
appearance of m in the quotation, no matter how deeply nested.

Oh. I just thought of something -- my flattening algorithm doesn't
handle [], so that'll have to be added. Simple, perhaps trivial.
Having noticed that, I'll note the obvious: T([]) = [] swap.

What an interesting transform.

> The insight of flattening is particularly helpful.

You flatter me.

...but this may be the first time flattening has been helpful. I hope
you intend to use it for good and not evil.

> - Christopher

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