Re: [stack] sweetening concatenative syntax

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
John Nowak <[email protected]> wrote:
> William Tanksley, Jr wrote:

>  > Cool! So 'unlist' does exactly what FunForth does (well, it's
>  > typesafe, unlike FunForth).

>  > I suppose I don't get why lambdas help with that, then. I assumed you
>  > were talking about pattern matching, since lambdas there could fit
>  > into the pattern, therefore helping you notate what is being
>  > extracted. But if you're only disassembling the parts of a structure,
>  > I don't see why you have to give the parts names.

>  Ah, sorry if I've confused you.

No prob -- my ignorance is not your responsibility.

> Lambdas don't have anything to do with
> it; they just let you write it in a way that makes it look more like
> pattern matching. You can write it without variables if you prefer.
> You can even write it with just one variable which is actually nicer:
>     f map = []
>             [xs -> f i xs f map cons]
>           unlist

Okay, so the challenge is to write that entirely without variables
(i.e. without the benefit of lambdas). Let's try. I'll prototype it
with my stack-shuffles, 'cause I like 'em.

\ f = a function, x = car, s = cdr, y=x f i
map = [] [ fxs--sfxf i sfy--ysf map cons ] unlist

Okay, translate the shuffle notation to familiar operators:
map = [] [ bury over i rot map cons ] unlist

(I define 'bury' as the inverse of 'rot'. Forth calls it '-rot'. I
prefer shuffles when possible, since a shuffle is essentially a
mnemonic name for a series of stack operators, but let's go with what
most people expect.)

Arguably no worse than yours; the body of my definition contains six
words, matching yours if we don't count your lambda and its variable
(beating it otherwise). I consider it an advantage that mine uses only
verbs, while yours mixes nouns and verbs.

>  - John

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