> It is not always a good thing to expand the domain of a verb. If
> youexpanded the domain of + to include characters
'aa' -: 'a'+'a'
is an abomination, though not appropriate to the more general 'null argument
handling' behaviour of built in functions.
A high priority beyond this philosophy point is not turning past J behaviour
into new errors.
if + represents the canonical J function,
'' -: 2 + i.0
1
I am not arguing to make any change to this canonical behaviour, but in fact,
to avoid temptation to change the behaviour into an error.
A useful J concept that could be a basis for / implementation behaviour is a
unit adverb that returns the non-null argument of a function when one argument
is null. Adverb defined as one line for ease,
unit =: 1 : ('if. x -: '''' do. y return. end.';'if. y -: '''' do. x return.
end.'; 'x u y')
and a performance optimization for only concerning programmer with empty/null x
argument
unity =: 1 : ('if. x -: '''' do. y return. end.'; 'x u y')
just as
+/ 2
2
'' +unit 2
2
'' -: +&>/ a: , ;/ i.5
1
+unity&>/ a: , ;/ i.5
10
+&>/ ;/ i.5
10
sorry that this has nothing to do with '' p. y behaviour, but unit dyad
functionality is perhaps worth conceptualizing, and understanding as a J result
moditifer to internal/other functions..
On Tuesday, January 3, 2023 at 10:40:08 p.m. EST, Henry Rich
<[email protected]> wrote:
You are essentially saying that ((i. 0) p. y) should be defined the same
as (0 p. y). I see no justification for this. We don't treat (i. 0) as
identical to (0). (i. 0) is not a polynomial and trying to make it one
is a kludge that will come to grief. I think it already has:
What is the integral of (i. 0)?
If (i. 0) as a polynomial is the same as 0, the answer has to be 0 1,
which is inconsistent with simple definitions.
It is not always a good thing to expand the domain of a verb. If you
expanded the domain of + to include characters, there would be fewer
errors but much more gnashing of teeth by users. I say that if a user
thinks that x is a polynomial and x is empty, they have a bug and the
sooner they learn that, the better.
Henry Rich
On 1/3/2023 5:06 PM, Raul Miller wrote:
> In J807:
>
> (i.0) p. 2
> 0
>
> In the current j904 beta:
>
> (i.0) p. 2
> |domain error, executing dyad p.
> |polynomial may not be empty
> | (i.0) p.2
>
> I think this change should be reverted.
>
> I have not researched the full history of this change, but J
> polynomials may be padded with an arbitrary number of trailing zeros
> without changing their significance. So, mathematically speaking,
> empty polynomials should be within the domain of the p. verb.
>
> But, also, this breaks typical general case implementation of a
> derivative operation on polynomials. In other words, this worked fine
> under j807:
>
> pderiv=: 1 }. (* i.@#)
> (pderiv 5) p. 2
> 0
>
> Thanks,
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm