What I meant was, if I have defined plus =: +
then +"1 and plus"1 should always get the same result. (That's why I wrote 'plus' rather than 'f'). The interpreter doesn't need to know that + and plus are the same. All it needs to do is follow the rule for empties, which requires checking the type, because the cell of fills is typed. I don't remember how I got into looking at 5+"1 (0 1$' ') but that isn't important. The practical difference to me between 0 1$0 and 0$0 is that (0 1$0) , 0$0 0 (0 1$0) , 0 1$0 in other words, the wrong shape produces a list with one item when it should have 0 items. Maybe that won't matter - it might just be something on the screen a few seconds. Or, it might be a list of stock transactions to perform, in which case I will incorrectly commit 25% of my net worth to a bad stock. (This has actually happened. Last time the stock went up). So I really want rules to go by. Learning by experiment can be awfully expensive. Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of R&S HUI > Sent: Wednesday, July 05, 2006 9:14 PM > To: Beta forum > Subject: Re: [Jbeta] Incorrect result shape from 5 +"1 (0 1 $' ') > > > surely it is much more important for +"1 and plus"1 > > to produce absolutely the same results. > > Surely? How does it know that + and plus are the same? > > plus=: 4 : 0 " 0 > if. ?2e9 do. x+y else. x-y end. > ) > > And can you tell me why this question (the shape of > 5+"1 (0 1$' ')) has more practical interest than the > number of angels that can dance on a transistor? > > > > ----- Original Message ----- > From: Henry Rich <[EMAIL PROTECTED]> > Date: Wednesday, July 5, 2006 5:25 pm > Subject: RE: [Jbeta] Incorrect result shape from 5 +"1 (0 1 $' ') > > > The shape calculus that the interpreter 'knows' should > > include the type. > > > > You give a good rule for how zero frame is handled. > > There is no reason to require 5 +"1 s$0 to give > > the same result as 5 +"1 s$'a' ; at least none that > > justifies deviating from that rule, IMO. > > > > Whatever shape calculus is built into the interpreter > > should match the rule. We could debate whether > > f 0 1$'a' should or should not match f 0 1$0, but > > surely it is much more important for +"1 and plus"1 > > to produce absolutely the same results. They almost > > do now, and if you follow your rule, they will completely. > > > > > > "It's not what the interpreter doesn't know that hurts > > you; it's what the interpreter knows that ain't so." > > -- traditional > > > > Henry Rich > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [EMAIL PROTECTED] On Behalf Of R&S HUI > > > Sent: Wednesday, July 05, 2006 7:19 PM > > > To: Beta forum > > > Subject: Re: [Jbeta] Incorrect result shape from 5 +"1 (0 1 $' ') > > > > > > There are competing rationale for what the result of > > > 5+"1 (0 1$'a') should be. A pretty strong one is > > > the identity > > > > > > s -: $ 5 +"1 s$0 [ s=: 10 ? 100 > > > > > > So $ 5+"1 (0 1$' ') should be 0 1 , and it is the > > > other results that are "wrong". > > > > > > I say "wrong" because that is the best that the > > > interpreter can do. For an arbitrary verb (of which > > > plus=: 4 : 'x+y'"0 and plus=:+ are examples) the > > > interpreter can not figure out in general what the > > > shape of the result should be. > > > > > > The rule is something like this for a zero frame: > > > If the interpreter "knows" the shape calculus for a verb, > > > it applies it. If it does not, it applies the verb to a > > > cell of fills, and assumes that the shape of the result > > > is typical; and if in such application there is an error, > > > it assumes the result is an atom. And: what the interpreter > > > "knows" can expand from version to version. > > > > > > > > > > > > ----- Original Message ----- > > > From: Henry Rich <[EMAIL PROTECTED]> > > > Date: Tuesday, June 27, 2006 12:04 pm > > > Subject: RE: [Jbeta] Incorrect result shape from 5 +"1 (0 1 $' ') > > > > > > > plus =: + > > > > $ 5 plus"1 (0 1 $' ') > > > > 0 > > > > > > > > This works correcly too, so I guess integrated rank support > > > > in + is implicated. > > > > > > > > Henry Rich > > > > > > > > > -----Original Message----- > > > > > From: [EMAIL PROTECTED] > > > > > [EMAIL PROTECTED] On Behalf Of Henry Rich > > > > > Sent: Tuesday, June 27, 2006 2:56 PM > > > > > To: 'Beta forum' > > > > > Subject: [Jbeta] Incorrect result shape from 5 +"1 (0 1 $' ') > > > > > > > > > > The rules are not made explicit for what happens when a > > > > > verb fails when applied to a fill cell, but I have deduced > > > > > by experiment that the interpreter behaves as if the > > > > > failing result were a scalar numeric. Thus: > > > > > > > > > > plus =: 4 : 'x + y'"0 > > > > > $ 5 plus"1 (0 1 $' ') > > > > > 0 > > > > > > > > > > Correct: 5 +"1 (1 $ ' ') failed, so ($0) was used as the > > > > > result shape from the fill-cell, and that was extended with > > > > > the frame (,0) to give a final result shape of ,0 . > > > > > > > > > > $ 5 +"1 (0 1 $' ') > > > > > 0 1 > > > > > > > > > > Incorrect: should be the same result as above, but apparently > > > > > special code for the + verb did not take into account the > > > > > subtleties of fill-cell processing and assigned the result > > > > > to have the same shape as the array operand. > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
