## Right-operand currying vs Stranding

For users of dfns, both novice and expert

### Re: Right-operand currying vs Stranding

Strange beast *. I guess 3∘* and 10∘* could also be useful if we're dealing with ternary or decimal arithmetic. It feels to me as if ⍺∘* and *∘⍵ are somehow completely unrelated monadic functions, each defining its own substantive argument, if we go with Phil's definition. I wonder if * is stange because it's non-associative, which puzzles me given this derivation:
`      succ←1∘+         ⍝ successor function      sum←{succ⍣⍺⊢⍵}    ⍝ sum in terms of succ: commutative and associative      prod←{⍺∘sum⍣⍵⊢0}  ⍝ product in terms of sum: commutative and associative      exp←{⍺∘prod⍣⍵⊢1}  ⍝ exp in terms of prod: neither commutative nor associative`
Is there a mathematician in the house?
JohnS|Dyalog

### Re: Right-operand currying vs Stranding

I should want to define the substantive argument of a dyad, if there is one, to be the one that cannot reasonably or usefully be bound.

I think trying to define “substantive argument” or “auxiliary argument” is a losing proposition. While it’s true that many APL primitive dyadic functions are designed so that fixing the left argument makes a sensible monadic functions, it does not preclude that fixing the right argument would make a sensible function.

Code: Select all
`*∘2           ⍝ square-∘1           ⍝ decrement1∘-           ⍝ complementary probability⍳∘1           ⍝ first 1⎕a∘⍳          ⍝ letter to alphabet index⌊/ ⍳∘'AEIOU'  ⍝ index of first voweletc.`

Also, if fixing one of the arguments does not seem to make a sensible monadic function, perhaps we haven’t thought about it hard enough? For example ⍴∘scalar is a function that makes a constant function with a specified shape, ⍴∘1 0 makes a checkerboard on odd arguments, and e∘* is the exponential function (in addition to the other exceptions already mentioned).

Also, why do we need to name “the argument to be fixed (curry-ed)” and “the argument to be supplied to the resultant monadic function”? These are no different from what are required for operators other than ∘.
Roger|Dyalog

Posts: 215
Joined: Thu Jul 28, 2011 10:53 am

### Re: Right-operand currying vs Stranding

* embodies a lot of the history of mathematics, and the notation is only arrived at after a long gestation. I believe that:

• It started as square, cube, ... in other words, *∘2, *∘3, etc. There wasn’t a unifying notation for these, just square, cube, ... as separate functions.

• Curious minds investigated inverses of these functions, thus *∘(÷2), *∘(÷3), ... . And voilà, irrational numbers were invented (or discovered, if you like). Again, no unifying notation, just square root, cube root, etc.

• Much later, other curious minds investigated square root on negative numbers, and voilà complex numbers were invented.

• A little before the previous, the exponent function was invented. The inverse function, natural logarithm, was invented around the same time.

• With the power laws, any b*x can be computed as (*⍟b)*x ←→ *(⍟b)×x

• Don’t know when it happened, but it was eventually realized that negative, non unit fraction (non reciprocals of integers), and real exponents also make useful functions. Before that, there was at least one author who used Roman numerals for exponents!

• I am skipping talking about polynomials, polynomial roots, algebraic functions, etc.
It is not obvious to me that the derivation of the power function presented in John’s message leads to a function which is commutative and/or associative. A similar sequence is arrived at from the Ackermann function.

Code: Select all
`ack←{ 0=⍺: 1+⍵ 0=⍵: (⍺-1) ∇ 1 (⍺-1) ∇ ⍺ ∇ ⍵-1}`

Since the discussion has been on A∘f and f∘A, it seems appropriate to present the following pot of Curry:

Code: Select all
`0∘ack = 1∘+⍢(3∘+)1∘ack = 2∘+⍢(3∘+)2∘ack = 2∘×⍢(3∘+)3∘ack = 2∘*⍢(3∘+)4∘ack = */∘(⍴∘2)⍢(3∘+)5∘ack = {*/∘(⍴∘2)⍣(1+⍵)⍢(3∘+) 1}`

(Note the ⍴∘2, Mr. Last. :-)

A derivation these relationships was first provided in J in 1992 and recently in Vector Volume 26, Number 2. The key is the lemma: If ⍺ ack ⍵ ←→ f⍢(3∘+) ⍵ , then (⍺+1)ack ⍵ ←→ f⍣(1+⍵)⍢(3∘+) 1.
Roger|Dyalog

Posts: 215
Joined: Thu Jul 28, 2011 10:53 am

### Re: Right-operand currying vs Stranding

I just think it's a concept that has a degree of usefulness in certain cirumstances - there are probably none where it's absolutely clear cut for all possible arguments to any particular function or operator. We don't need a name for them any more than we need the names monadic and dyadic (say) but naming concepts is sometimes useful. Why do we need azure when we have sky blue?

Phil Last

Posts: 557
Joined: Thu Jun 18, 2009 6:29 pm

### Re: Right-operand currying vs Stranding

I wonder if * is strange because it’s non-associative, which puzzles me given this derivation: ...

It’s easy to see from simple examples that * is non-commutative and non-associative:

Code: Select all
`      2*3           ⍝ non-commutative8      3*29      2*(3*4)       ⍝ non-associative2.41785E24      (2*3)*44096`

Whence it doesn’t matter what derivation is used, it’d still be non-commutative and non-associative.
Roger|Dyalog

Posts: 215
Joined: Thu Jul 28, 2011 10:53 am

Previous