All that's as should be... except the crash.  That is now fixed for the next beta.  The code was passing inplacing info to a gerund that couldn't take it.

Thanks for the testing,

Henry Rich

On 6/8/2020 12:03 PM, Devon McCormick wrote:
This seems to crash J 9.02 under Windows 10:
    test2 =. (1&+)`(2&*)`(3&%~) @. (3&|)
    test2 i.7
In J 9.01, I get rank errors for arguments of "i.6" and "i.7" with this
definition.

This
    test3 =. (1+])`(2*])`(3%~]) @. (3&|)
gives the expected result in 9.02 but a rank error in 9.01.  However if I
define this
    test4 =. (1+])`(2*])`(3%~]) @. (3&|)"0
it gives the same answer in 9.01 as "test3" gives in 9.02.


On Mon, Jun 8, 2020 at 10:10 AM Henry Rich <[email protected]> wrote:

0: ` 1: ` 2: @. (3&|)"0

is the same as

(0: ` 1: ` 2: @. (3&|))"0

you are running the whole agenda at rank 0, processing each
argument-atom separately and assembling the results.


If instead you use

0: ` 1: ` 2: @. ((3&|)"0)

you haven't achieved anything: (3&|) and (3&|)"0 produce the same
result, and (3&|)"0 is slower because of the rank looping.


Part of your problem here is that you are using toy gerunds.  0: has
infinite rank and produces an atom no matter what the argument.  (2&+)
on the other hand has infinite rank, but it produces a result with the
shape of its argument.  You want to use gerunds like (2&+), whose
result-shape depends on the argument-shape.


I can't produce a rank error for (test1 i. 6).   There are two paths in
the gerund code: the old-fashioned way, executing one gerund on each
cell, for use when there are few cells; and the new way, which collects
the cells that have the same selector and executes each gerund once on
an array of those cells.  The new way is much faster when there are many
cells, but it fails if the verb is ill-behaved when given a list of
cells.  The old way works even if the verb is ill-behaved.  If I am
going to use the old way, I have no way of divining that the new way
would have failed, which is what it would take to raise a rank error.

Henry Rich

On 6/8/2020 8:45 AM, çağlar girit wrote:
Hello Henry,

Yes I'm using J9.02. I saw your explanation in the NuVoc writeup about
the
implied rank and had solved the problem as you show in the examples,

     test2 =. 0: ` 1: ` 2: @. (3&|)"0
by specifying the rank of the test-verb instead of each gerund-verb. From
the discussion at the bottom of the page, using atomic rank for the
test-verb is more efficient than specifying for the gerund-verbs, right?

Since test1 didn't throw a rank error for i.6, and from reading the
writeup
it seemed like it should, I thought I must be missing something deeper.
As
a J beginner I blame my understanding of the language rather than the
beta.
Perhaps it would be good if J9.02 also threw a rank error.

Thanks,
Çağlar


--
This email has been checked for viruses by AVG.
https://www.avg.com

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




--
This email has been checked for viruses by AVG.
https://www.avg.com

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

Reply via email to