Becomes even clearer if you define:
plus=: (4 : '<(":>x),''+'',(":>y)')"0
plus/a
┌───────┬───────┬───────┬───────┐
│0+8+16 │1+9+17 │2+10+18│3+11+19│
├───────┼───────┼───────┼───────┤
│4+12+20│5+13+21│6+14+22│7+15+23│
└───────┴───────┴───────┴───────┘
plus/"1 a
┌───────────┬───────────┐
│0+1+2+3 │4+5+6+7 │
├───────────┼───────────┤
│8+9+10+11 │12+13+14+15│
├───────────┼───────────┤
│16+17+18+19│20+21+22+23│
└───────────┴───────────┘
plus/"2 a
┌─────┬─────┬─────┬─────┐
│0+4 │1+5 │2+6 │3+7 │
├─────┼─────┼─────┼─────┤
│8+12 │9+13 │10+14│11+15│
├─────┼─────┼─────┼─────┤
│16+20│17+21│18+22│19+23│
└─────┴─────┴─────┴─────┘
On Thu, Jun 9, 2011 at 5:25 AM, Kip Murray <[email protected]> wrote:
> A source of confusion for a newcomer can be that the items of an array are
> shown
> in a vertical list except when the array is a vector the items are shown in a
> horizontal list. Thus in the array
>
> ]a =: 3 2 4 $ i. 24
> 0 1 2 3
> 4 5 6 7
>
> 8 9 10 11
> 12 13 14 15
>
> 16 17 18 19
> 20 21 22 23
>
> the items are three 2 by 4 arrays shown in a vertical list, the items of each
> item are two 4-vectors shown in a vertical list, but the items of the items of
> the items are four scalars shown in a horizontal list.
>
> Can you now understand
>
> +/a
> 24 27 30 33
> 36 39 42 45
> +/"2 a
> 4 6 8 10
> 20 22 24 26
> 36 38 40 42
> +/"1 a
> 6 22
> 38 54
> 70 86
>
> ?
>
> Kip Murray
>
> On 6/8/2011 4:47 PM, Henry Rich wrote:
>> You almost had it. I've fixed the error below.
>>
>> Henry Rich
>>
>> On 6/8/2011 5:41 PM, Squint6 wrote:
>>>
>>> Hi,
>>>
>>>
>>> I have just started with J and I have a question concerning rank (I think).
>>>
>>>
>>> I don't understand why the following does what it does:
>>>
>>>
>>> a=. 2 2 $ i.4
>>>
>>>
>>> b=.+/a
>>>
>>>
>>> c=.+/"1 a
>>>
>>>
>>> After executing these lines
>>> a contains
>>> 0 1
>>> 2 3
>>> b contains 2 4 and
>>> c contains 1 5
>>>
>>>
>>> I understand where b is coming from but c's value confuses me. Here's how
>>> my (faulty) reasoning about c=.+/"1 a goes.
>>
>>> The "1 applies to the verb (+/) giving it a rank of 1. Therefore (+/) is
>>> applied to the 1-cells of a,
>>
>>> which I believe are the lists (0 1) and (2 3).
>> ERROR FIXED HERE:
>>> Therefore we have (+/ 0 1) , (+/ 2 3)
>>>
>>>
>>> Thanks.
>>> Kent
>>>
>>>
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm