Page 1 of 1

Dealing With Higher Rank Arrays

Posted: Tue Jul 16, 2013 3:07 pm
by conor_f
I am trying to get to grips with arrays of rank > 2. I have read the relevant sections of "Mastering Dyalog APL" and searched the APLwiki, but am still not satisfied. An example I could get a start from would be ideal for me, so if someone could show me a short section of code in which an array of rank ≥ 3 is created and initialised to some values, has items appended and dropped from it and an example of the effects of operators/functions like ¨ , / . etc, I would be very grateful.

Thanks in advance

Re: Dealing With Higher Rank Arrays

Posted: Wed Jul 17, 2013 7:24 pm
by Roger|Dyalog
Ken Iverson (inventor of APL) liked to use the following analogy: numbers, lists, tables, reports, files, drawers, cabinets, aisles, floors, warehouses, ...

Examples:

      ⎕rl←7*5            ⍝ to get reproducible random numbers
⎕io←0 ⍝ because I detest 1-origin

x←?5 4 3⍴100 ⍝ random numbers for testing
⍝ sales in 5 countries, 4 quarters, and 3 months in a quarter

+/x ⍝ sales in each country by quarter
+/[2] x ⍝ ditto

+/[0] x ⍝ sales for each month

+/[1]+/[2] x ⍝ sales in each country

+/[0]+/[1]+/[2] x ⍝ total sales
+/,x ⍝ ditto

Re: Dealing With Higher Rank Arrays

Posted: Fri Jul 19, 2013 10:51 am
by conor_f
Great, thanks. Just takes a bit to get used to them I suppose.