Rightoperand currying vs Stranding
15 posts
• Page 2 of 2 • 1, 2
Re: Rightoperand 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 nonassociative, which puzzles me given this derivation:
succ←1∘+ ⍝ successor functionIs there a mathematician in the house?
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
 JohnSDyalog
Re: Rightoperand 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 ⍝ decrement
1∘ ⍝ complementary probability
⍳∘1 ⍝ first 1
⎕a∘⍳ ⍝ letter to alphabet index
⌊/ ⍳∘'AEIOU' ⍝ index of first vowel
etc.
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 (curryed)” and “the argument to be supplied to the resultant monadic function”? These are no different from what are required for operators other than ∘.
 RogerDyalog
 Posts: 210
 Joined: Thu Jul 28, 2011 10:53 am
Re: Rightoperand 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:
Since the discussion has been on A∘f and f∘A, it seems appropriate to present the following pot of Curry:
(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.
 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.
 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.
 RogerDyalog
 Posts: 210
 Joined: Thu Jul 28, 2011 10:53 am
Re: Rightoperand 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: 549
 Joined: Thu Jun 18, 2009 6:29 pm
Re: Rightoperand currying vs Stranding
I wonder if * is strange because it’s nonassociative, which puzzles me given this derivation: ...
It’s easy to see from simple examples that * is noncommutative and nonassociative:
 Code: Select all
2*3 ⍝ noncommutative
8
3*2
9
2*(3*4) ⍝ nonassociative
2.41785E24
(2*3)*4
4096
Whence it doesn’t matter what derivation is used, it’d still be noncommutative and nonassociative.
 RogerDyalog
 Posts: 210
 Joined: Thu Jul 28, 2011 10:53 am
15 posts
• Page 2 of 2 • 1, 2
Return to Functional Programming
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group