On Fri, Jan 11, 2013 at 10:07 PM, Linda Alvord <[email protected]> wrote:
> I don't understand why f and g do not agree?
Because they are doing something different.
> #&>'one';'two';'three'
> 3 3 5
> f=: 13 :'#&>y'
> f 'one';'two';'three'
> 3 3 5
f counts the number of items in each box.
> NB. Compose: u&v y ↔ u v y
>
> g=: 13 :'#>y'
> g=: 13 :'#>y'
> g 'one';'two';'three'
> 3
g counts the number of items after unboxing.
Let's try replacing # with <
<@> 'one';'two';'three'
+---+---+-----+
|one|two|three|
+---+---+-----+
<> 'one';'two';'three'
+-----+
|one |
|two |
|three|
+-----+
Or, let's change the data and use $
$@> i.each 2 2; 3 3; 4 4
2 2
3 3
4 4
$> i. each 2 2; 3 3; 4 4
3 4 4
Remember that > has rank 0 so F@> is going to run an independent
instance of F for each box that you are unpacking.
Does this help?
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm