Re: [stack] adding construction to Joy-like languages

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Dec 29, 2008, at 10:05 PM, John Nowak wrote:

> Something marginally more useful:
>
>   discriminant = 3g [|2nd sq, [|1st, 3rd|] * 4 *|] -
>
> Useful? I'm not sure. The need to group things into a single vector
> all the time means it is still less convenient than the FP version...
> This is especially if we use an infix syntax (e.g. 'f g h == g:[f,
> h]') like J's monadic hook:
>
>   discriminant = (sq 2nd) - 4 * 1st * 3rd  -- all associate right

I suppose I could be more fair in my comparison; I managed to throw  
out all the benefits of the concatenative programming style in my  
example as I was doing a direct FP translation. Here's a better version:

   3g [|2nd sq, 4 * *|] -

Compare to what you'd probably write in Factor now:

   [sq swap] dip 4 * * -

I think the first version is better. It's clear that you're dealing  
with three values, clear you're squaring the second, clear you're  
getting two results and then taking the difference, etc.

I can't help but think there's some good way to combine FP with Joy- 
style languages. I think using More-style vectors as the primary data  
structure may be a good start.

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