rslt ← (fun ##.rows) {array}    ⍝ Operand function applied to argument rows.

Many  functions expect a simple vector or scalar, such as a "name", as argument.
This  operator  accepts any rank or depth array and applies its function operand
to each simple vector or scalar therein.

NB: much of the utility of this operator is now superseded by the primitive rank
operator ⍤.

Examples:

isdfn rows 'a'⎕nl 3                     ⍝ Fn applied to each row of matrix.
1 1 1

{'<',⍵,'>'} rows 'ten' 'a' 'penny'      ⍝ Scalars are OK, too.
<ten>  <a>  <penny>

mats                                    ⍝ A vector of matrices.
┌─────┬──────┬───────┐
│eight│hovera│hickory│
│nine │dovera│dickory│
│ten  │dik   │dock   │
└─────┴──────┴───────┘

{⍴⍵~' '} rows mats                      ⍝ Fn applied to each matrix row.
┌─┬─┬─┐
│5│6│7│
│4│6│7│
│3│3│4│
└─┴─┴─┘

{+/⍵≠' '} rows mats                     ⍝ Rows collapse to scalars.
┌─────┬─────┬─────┐
│5 4 3│6 6 3│7 7 4│
└─────┴─────┴─────┘

{⍵[⍋⍵]} rows mats                       ⍝ Sort each row.
┌─────┬──────┬───────┐
│eghit│aehorv│chikory│
│  ent│   dik│   cdko│
└─────┴──────┴───────┘

display rows mats                       ⍝ Display each row.
┌→────┐  ┌→─────┐  ┌→──────┐
│eight│  │hovera│  │hickory│
└─────┘  └──────┘  └───────┘

┌→────┐  ┌→─────┐  ┌→──────┐
│nine │  │dovera│  │dickory│
└─────┘  └──────┘  └───────┘

┌→────┐  ┌→─────┐  ┌→──────┐
│ten  │  │dik   │  │dock   │
└─────┘  └──────┘  └───────┘

cuboid                                 ⍝ Numeric 3×4×5-array.
1  2  3  4  5
6  7  8  9 10
11 12 13 14 15
16 17 18 19 20

21 22 23 24 25
26 27 28 29 30
31 32 33 34 35
36 37 38 39 40

41 42 43 44 45
46 47 48 49 50
51 52 53 54 55
56 57 58 59 60

{+/⍵÷⍴⍵} rows cuboid                    ⍝ Row-averages.
3  8 13 18
23 28 33 38
43 48 53 58

Back to: contents

Back to: Workspaces