On 2/27/08, Roelof K Brouwer <[EMAIL PROTECTED]> wrote:
> repl_diag_by_minus_sum_of_row=: 3 : 't-I*+/"1 t=.(-.I=.=/~i.#y)*y'
> repl_diag_by_minus_sum_of_row=: 13 : 't-I*+/"1 t=.(-.I=.=/~i.#y)*y'
>
> applying them to i.5 5 gives two different results with the 2nd giving an
> unintended result

First off, I prefer to avoid names unless I can come up with
good names which are shorter than their expressions.

Second, I examined the expressions
   3 : 't-I*+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
   13 : 't-I*+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
and I think that the 13 : expression evaluator has a bug
which can be worked around by changing that second
expression to
   13 : 't-I*+/"[EMAIL PROTECTED] t=.(-.I=.=/~i.#y)*y' i. 5 5

Here's my thinking.  I tried:
   3 : 'I*+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
   13 : 'I*+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
these results were different

But when I tried
   3 : '+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
   13 : '+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
this pair of expressions gave me results that looked the same.

So I then looked at
   3 : 'I[+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
   13 : 'I[+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
and, again, my results looked similar.

So then I looked at
   3 : 'I;+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
   13 : 'I;+/"1 t=.(-.I=.=/~i.#y)*y' i. 5 5
and my results looked different.

So then I looked at the linear form for
      13 : 'I;+/"1 t=.(-.I=.=/~i.#y)*y'
which is
([: =/~ [: i. #) ([ ; +/"1) ([: -. [: =/~ [: i. #) * ]

And, here, I can see that the verb ([ ; +/"1)
treats +/"1 as a dyad but the original expression
used it as a monad.

I can force it to be treated as a monad by replacing
+/"1 with +/"[EMAIL PROTECTED]

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to