On Thu, Jul 16, 2009 at 8:08 PM, <[email protected]> wrote:
> testSet =: (1; ((3,4); 8; (8,9)); 10)
>
> 0 } testSet returns a boxed 1
> 2 } testSet returns a boxed 10
> 1 } testSet returns a boxed ((3 4); 8; (8 9))
>
> I would have expected the last set returned to have a rank
> of 3 and not a rank of 1.

Have you displayed these results?

You get a single box which has three things inside of it.  Until
you take them out of the box, though, you just have that one
containing box.

That said, "rank" usually means the result of #...@$ and not
the result of # by itself (which would be "tally").  (The rank
of each of your results, in the usual sense of the word, would
have been zero.)

> I would like to do
>
> 1 } ( 1 } testSet ) to get 8, but get an index error
> because # (1 } testSet) is rank of 1

You have a lot of ways of accomplishing this, including:

   1{::1{::testSet
8
   (1;1) {:: testSet
8
   >1}>1}testSet
8
   >1{>1{testSet
8

That said, technically speaking, if you are concerned about
the indices of items you are no longer treating their collection
as a set but as a sequence.  Then again, "set" is a shorter
word than "sequence", but you could also call them an
"array" or a "list".

FYI,

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

Reply via email to