Calling all Dfnistas!
7 posts
• Page 1 of 1
Calling all Dfnistas!
Much to my amusement, the opportunity to productively use ∇∇ arose just the other day - a first for me.
This brings up the question: why not just a single ∇ for operator self-reference? I don't see how both a single and double del would be meaningful in the same function or operator. However, as I write this, it dawns on me that in an operator with nested dfns, an inner dfn might want to refer to itself and to the outer operator*. Hmm...is that why?
*I hope I never find myself in that situation.
This brings up the question: why not just a single ∇ for operator self-reference? I don't see how both a single and double del would be meaningful in the same function or operator. However, as I write this, it dawns on me that in an operator with nested dfns, an inner dfn might want to refer to itself and to the outer operator*. Hmm...is that why?
*I hope I never find myself in that situation.
- paulmansour
- Posts: 433
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Calling all Dfnistas!
Hey Paul
Without reference to the reference this is the way I look at it. First off and without trying it I think that within a dfn ∇∇ has no meaning.
But within a dop, as within a dfn, ∇ means the current function.
So within a dop it's not a reference to itself but to the derived function; that is: the dop itself bound with its operands.
Now lets say we've written an operator - in this case an adverb (monadic operator) - that has a wide range of application.
This use of ∇∇ at the time was completely fanciful as even then the operator could have been written much more succinctly with ∇ replacing the whole of ⍺⍺ ∇∇ ⍺⍺ and the final guard ⍵:⍵≡⍺ missing entirely as it follows an unassigned result returning expression.
My reason was that in developing the dop it had begun to look rather symmetrical and I then spent as long folding it into a palindrome as I had in working out the mechanics.
The final version waa demonstrated by JS in a silly video that's probably still up in YouTube. It is nowhere used in any of my subsequent code and it's slightly more elegant derived adverb equivalent ⍣≡ is used only twice therein.
Nor have I had recourse to use ∇∇ elsewhere - not once.
Without reference to the reference this is the way I look at it. First off and without trying it I think that within a dfn ∇∇ has no meaning.
But within a dop, as within a dfn, ∇ means the current function.
So within a dop it's not a reference to itself but to the derived function; that is: the dop itself bound with its operands.
Now lets say we've written an operator - in this case an adverb (monadic operator) - that has a wide range of application.
.Here's one I wrote earlier - much earlier - before JS implemented the power operator ⍣.
lm←{
⍵ ⍺⍺{⍺≡⍵:⍵ ⋄ ⍵ ⍺⍺ ∇∇ ⍺⍺ ⍵ ⋄ ⍵:⍵≡⍺}⍺⍺ ⍵
⍝ limit ←→ ⍣≡
}
This use of ∇∇ at the time was completely fanciful as even then the operator could have been written much more succinctly with ∇ replacing the whole of ⍺⍺ ∇∇ ⍺⍺ and the final guard ⍵:⍵≡⍺ missing entirely as it follows an unassigned result returning expression.
My reason was that in developing the dop it had begun to look rather symmetrical and I then spent as long folding it into a palindrome as I had in working out the mechanics.
The final version waa demonstrated by JS in a silly video that's probably still up in YouTube. It is nowhere used in any of my subsequent code and it's slightly more elegant derived adverb equivalent ⍣≡ is used only twice therein.
Nor have I had recourse to use ∇∇ elsewhere - not once.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Calling all Dfnistas!
Again without recourse to actually trying it I don't believe your suggestion would be possible to reference the outside dop from a nested dfn therein.
Or let's say it may be possible because no-one ever got round to writing code that would prevent it but remembering what I do of JS's hopes and aims I doubt very much that he would have approved of its use.
Or let's say it may be possible because no-one ever got round to writing code that would prevent it but remembering what I do of JS's hopes and aims I doubt very much that he would have approved of its use.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Calling all Dfnistas!
Doh!
So my use of
Could easily be replaced by
Obviously now in hindsight. So then the only real use of ∇∇ is if the operands might vary on each recursive call?
So my use of
⍺ ⍺⍺ ∇∇ ⍵
Could easily be replaced by
⍺ ∇ ⍵
Obviously now in hindsight. So then the only real use of ∇∇ is if the operands might vary on each recursive call?
- paulmansour
- Posts: 433
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Calling all Dfnistas!
I never could find a requirement for that - though I did try - perhaps Adam may have done?
Apologies for lack of diacritic Adam.
Apologies for lack of diacritic Adam.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Calling all Dfnistas!
∇∇ is especially useful when normalising or iterating operands, most commonly with array operands, but it can also happen with function operands:
The right operand of Rank (⍤) is normalised to ⌽3⍴⌽ so one could imagine an implementation of Rank or a similar operator containing the guard
The At operator can collapse a function right operand to an array operand with code like
An nth derivative operator (assuming D is a simple derivative operator) can be stated as
And here's a backscan:
The right operand of Rank (⍤) is normalised to ⌽3⍴⌽ so one could imagine an implementation of Rank or a similar operator containing the guard
2≥≢⍵⍵:⍺(⍺⍺∇∇(⌽3⍴⌽⍵⍵))⍵
The At operator can collapse a function right operand to an array operand with code like
⍺(⍺⍺∇∇((⍵⍵(/⍥,)⍳⍤⍴)⍵)⍵
An nth derivative operator (assuming D is a simple derivative operator) can be stated as
{⍵⍵=1:⍺⍺D⍵ ⋄ ((⍺⍺D)∇∇(⍵⍵-1))⍵}
And here's a backscan:
{0≡≢⍵:⍬ ⋄ h←⍺ ⍺⍺⊃⍵ ⋄ (⊂h),h⍺⍺∇∇1↓⍵}
-
Adam|Dyalog - Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: Calling all Dfnistas!
Adam|Dyalog wrote:especially useful when ... iterating ... array operands
Thanks for that Adam. I've tried and, I think, succeeded in doing that but always more long-winded by demoting the array operand as an argument to reduction applied to an inner dop rather than linking it with a recursive call to the dop itself.
Your second and third examples look interesting and non-trivial but the guard in the first could most easily be replaced by something like i j k←⌽3⍴⌽⍵⍵ which, if the requirement is for 3=≢⍵⍵, is likely to be the next step.
The ⍺⍺∇∇ in your last example could of course be replaced with ∇ as with Paul's unseen example and my palindrome.
But thnks for demonstrating that ∇∇ is at least non-trivially useful.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group