```⍝ ⍺-combination matrix of ⍳⍵:

⎕io ⎕ml←1 0

display 0 cmat 5
┌⊖┐
↓0│
└~┘
display 1 cmat 5
┌→┐
↓1│
│2│
│3│
│4│
│5│
└~┘
display 2 cmat 5
┌→──┐
↓1 2│
│1 3│
│1 4│
│1 5│
│2 3│
│2 4│
│2 5│
│3 4│
│3 5│
│4 5│
└~──┘
display 3 cmat 5
┌→────┐
↓1 2 3│
│1 2 4│
│1 2 5│
│1 3 4│
│1 3 5│
│1 4 5│
│2 3 4│
│2 3 5│
│2 4 5│
│3 4 5│
└~────┘
display 4 cmat 5
┌→──────┐
↓1 2 3 4│
│1 2 3 5│
│1 2 4 5│
│1 3 4 5│
│2 3 4 5│
└~──────┘
display 5 cmat 5
┌→────────┐
↓1 2 3 4 5│
└~────────┘
display 6 cmat 5
┌→──────────┐
⌽0 0 0 0 0 0│
└~──────────┘

⍉↑{⍴⍵ cmat 5}¨0 to 6                        ⍝ Row and column sizes
1 5 10 10 5 1 0
0 1  2  3 4 5 6

2{⍵[⍺ cmat⍴⍵]}'scissors' 'paper' 'stone'    ⍝ 2-combos of nested vector
┌────────┬─────┐
│scissors│paper│
├────────┼─────┤
│scissors│stone│
├────────┼─────┤
│paper   │stone│
└────────┴─────┘

↓3{⍵[⍺ cmat⍴⍵]}'abcde'                      ⍝ 3-combos of char vector
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

⍕ display¨0 1 2 3∘.cmat 0 1 2 3             ⍝ Combos of small vectors
┌⊖┐      ┌⊖┐      ┌⊖┐      ┌⊖┐
↓0│      ↓0│      ↓0│      ↓0│
└~┘      └~┘      └~┘      └~┘
┌→┐      ┌→┐      ┌→┐      ┌→┐
⌽0│      ↓1│      ↓1│      ↓1│
└~┘      └~┘      │2│      │2│
└~┘      │3│
└~┘
┌→──┐    ┌→──┐    ┌→──┐    ┌→──┐
⌽0 0│    ⌽0 0│    ↓1 2│    ↓1 2│
└~──┘    └~──┘    └~──┘    │1 3│
│2 3│
└~──┘
┌→────┐  ┌→────┐  ┌→────┐  ┌→────┐
⌽0 0 0│  ⌽0 0 0│  ⌽0 0 0│  ↓1 2 3│
└~────┘  └~────┘  └~────┘  └~────┘

⎕io←0
2 cmat 4                            ⍝ Code is "origin sensitive"
0 1
0 2
0 3
1 2
1 3
2 3

⍉ ∘.{⍬⍴⍴⍺ cmat ⍵}⍨ 0 to 12          ⍝ Pascal's triangle
1  0  0   0   0   0   0   0   0   0  0  0 0
1  1  0   0   0   0   0   0   0   0  0  0 0
1  2  1   0   0   0   0   0   0   0  0  0 0
1  3  3   1   0   0   0   0   0   0  0  0 0
1  4  6   4   1   0   0   0   0   0  0  0 0
1  5 10  10   5   1   0   0   0   0  0  0 0
1  6 15  20  15   6   1   0   0   0  0  0 0
1  7 21  35  35  21   7   1   0   0  0  0 0
1  8 28  56  70  56  28   8   1   0  0  0 0
1  9 36  84 126 126  84  36   9   1  0  0 0
1 10 45 120 210 252 210 120  45  10  1  0 0
1 11 55 165 330 462 462 330 165  55 11  1 0
1 12 66 220 495 792 924 792 495 220 66 12 1

Back to: code

Back to: Workspaces
```