⍝ List ⍺-leaves of nested array:
vecs←(('hello' 'world')('bonjour' 'monde'))(('good' 'night')('bon' 'soir'))
vecs ⍝ uniform depth 4 array.
┌───────────────────────────────┬─────────────────────────┐
│┌─────────────┬───────────────┐│┌────────────┬──────────┐│
││┌─────┬─────┐│┌───────┬─────┐│││┌────┬─────┐│┌───┬────┐││
│││hello│world│││bonjour│monde│││││good│night│││bon│soir│││
││└─────┴─────┘│└───────┴─────┘│││└────┴─────┘│└───┴────┘││
│└─────────────┴───────────────┘│└────────────┴──────────┘│
└───────────────────────────────┴─────────────────────────┘
0 enlist vecs ⍝ list (vector) of depth-0 leaves.
helloworldbonjourmondegoodnightbonsoir
1 enlist vecs ⍝ list of depth-1 leaves.
┌─────┬─────┬───────┬─────┬────┬─────┬───┬────┐
│hello│world│bonjour│monde│good│night│bon│soir│
└─────┴─────┴───────┴─────┴────┴─────┴───┴────┘
2 enlist vecs ⍝ list of depth-2 leaves.
┌─────────────┬───────────────┬────────────┬──────────┐
│┌─────┬─────┐│┌───────┬─────┐│┌────┬─────┐│┌───┬────┐│
││hello│world│││bonjour│monde│││good│night│││bon│soir││
│└─────┴─────┘│└───────┴─────┘│└────┴─────┘│└───┴────┘│
└─────────────┴───────────────┴────────────┴──────────┘
3 enlist vecs ⍝ list of depth-3 leaves.
┌───────────────────────────────┬─────────────────────────┐
│┌─────────────┬───────────────┐│┌────────────┬──────────┐│
││┌─────┬─────┐│┌───────┬─────┐│││┌────┬─────┐│┌───┬────┐││
│││hello│world│││bonjour│monde│││││good│night│││bon│soir│││
││└─────┴─────┘│└───────┴─────┘│││└────┴─────┘│└───┴────┘││
│└─────────────┴───────────────┘│└────────────┴──────────┘│
└───────────────────────────────┴─────────────────────────┘
tea←2 2⍴('tea'4'two')(2'for' 'T')('me' '&' 'you')('u' 'and' 'me')
tea ⍝ non-uniform depth-3 array.
┌───────────┬──────────┐
│┌───┬─┬───┐│┌─┬───┬─┐ │
││tea│4│two│││2│for│T│ │
│└───┴─┴───┘│└─┴───┴─┘ │
├───────────┼──────────┤
│┌──┬─┬───┐ │┌─┬───┬──┐│
││me│&│you│ ││u│and│me││
│└──┴─┴───┘ │└─┴───┴──┘│
└───────────┴──────────┘
0 enlist tea ⍝ list of depth-0 leaves.
tea 4 two 2 forTme&youuandme
1 enlist tea ⍝ list of (at most) depth-1 leaves.
┌───┬─┬───┬─┬───┬─┬──┬─┬───┬─┬───┬──┐
│tea│4│two│2│for│T│me│&│you│u│and│me│
└───┴─┴───┴─┴───┴─┴──┴─┴───┴─┴───┴──┘
2 enlist tea ⍝ list of depth-2 leaves.
┌───────────┬─────────┬──────────┬──────────┐
│┌───┬─┬───┐│┌─┬───┬─┐│┌──┬─┬───┐│┌─┬───┬──┐│
││tea│4│two│││2│for│T│││me│&│you│││u│and│me││
│└───┴─┴───┘│└─┴───┴─┘│└──┴─┴───┘│└─┴───┴──┘│
└───────────┴─────────┴──────────┴──────────┘
chk←{⎕ml←1 ⋄ (enlist ⍵)≡∊⍵}
chk¨vecs tea ⍝ 0∘enlist agrees with primitive fn.
1 1
⍝∇ enlist
Back to: code
Back to: Workspaces