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

Reply via email to