Looking for a combinator name

Christopher Diggins — 2008-12-06 13:42:00

Hi all,

I am looking for a name for a combinator that is equivalent to:

In Cat: dip apply
Or in Joy: dip i

This turns out to be a very useful combinator when doing code
compression. Given two functions:

define f { a0 .. aN x b0 .. bN }
define g { a0 .. aN y b0 .. bN }

We can reduce the size by rewriting it as:

define h { [a0 .. aN] dip apply b0 .. bN }
define f { [x] h }
define g { [y] h }

Any suggestions would be appreciated.

- Christopher

John Nowak — 2008-12-07 13:08:04

On Dec 6, 2008, at 8:42 AM, Christopher Diggins wrote:

> I am looking for a name for a combinator that is equivalent to:
>
> In Cat: dip apply
> Or in Joy: dip i

I can't say that I understand what you'd use this for and hence I'm
having trouble coming up with a name. I've often used 'dup dip i' (aka
'twice'), but never just 'dip i'. Do you have a more concrete example?

- John

Christopher Diggins — 2008-12-07 17:28:45

On Sun, Dec 7, 2008 at 8:08 AM, John Nowak <john@...> wrote:
> On Dec 6, 2008, at 8:42 AM, Christopher Diggins wrote:
>
>> I am looking for a name for a combinator that is equivalent to:
>>
>> In Cat: dip apply
>> Or in Joy: dip i
>
> I can't say that I understand what you'd use this for and hence I'm
> having trouble coming up with a name. I've often used 'dup dip i' (aka
> 'twice'), but never just 'dip i'. Do you have a more concrete example?

No I don't. I have only seen it when refactoring concatenative code.

Lets call it q for a second:

... [a] [b] q => ... b a

I believe the following is the applicative form:

\abc.b(a(c))

Another way of writing it is:

q = swap compose apply

or in Joy:

q = swap cat i

- Christopher

Christopher Diggins — 2008-12-07 17:30:37

Just found a name at : http://tunes.org/~iepos/joy.html

Brent calls it "sap".

- Christopher

On Sun, Dec 7, 2008 at 12:28 PM, Christopher Diggins <cdiggins@...> wrote:
> On Sun, Dec 7, 2008 at 8:08 AM, John Nowak <john@...> wrote:
>> On Dec 6, 2008, at 8:42 AM, Christopher Diggins wrote:
>>
>>> I am looking for a name for a combinator that is equivalent to:
>>>
>>> In Cat: dip apply
>>> Or in Joy: dip i
>>
>> I can't say that I understand what you'd use this for and hence I'm
>> having trouble coming up with a name. I've often used 'dup dip i' (aka
>> 'twice'), but never just 'dip i'. Do you have a more concrete example?
>
> No I don't. I have only seen it when refactoring concatenative code.
>
> Lets call it q for a second:
>
> ... [a] [b] q => ... b a
>
> I believe the following is the applicative form:
>
> \abc.b(a(c))
>
> Another way of writing it is:
>
> q = swap compose apply
>
> or in Joy:
>
> q = swap cat i
>
> - Christopher
>