Dealing With Higher Rank Arrays

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

Dealing With Higher Rank Arrays

Postby conor_f on Tue Jul 16, 2013 3:07 pm

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
conor_f
 
Posts: 13
Joined: Wed May 29, 2013 7:33 pm

Re: Dealing With Higher Rank Arrays

Postby Roger|Dyalog on Wed Jul 17, 2013 7:24 pm

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
Roger|Dyalog
 
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am

Re: Dealing With Higher Rank Arrays

Postby conor_f on Fri Jul 19, 2013 10:51 am

Great, thanks. Just takes a bit to get used to them I suppose.
conor_f
 
Posts: 13
Joined: Wed May 29, 2013 7:33 pm


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest