§ identity matrix
n←3 ⋄ id ← n n ⍴(1,n⍴0) ⋄ idThis relies heavily on ⍴ replicating its arguments.
§ histogram
xs←(1 1 3 3 3 6) ⋄ n←(⌈/xs)⍴0 ⋄ n[xs]+←1 ⋄ nThe use of n[x] +←1 will stably write +1 as many times as there are repeated
indexes in xs.
§ String matching / parity as fold ≠:
]disp str ← (1 0 0 1 0 0 0 0 1 0 1 0 0 0) ⋄ 2 1 ⍴ ((⊂ str) ⍪ ⊂((≠\str)))┌→──────────────────────────┐↓1 0 0 1 0 0 0 0 1 0 1 0 0 0│├~─────────────────────────→┤│1 1 1 0 0 0 0 0 1 1 0 0 0 0│└~─────────────────────────→┘