Depth{                                 ⍝ Apply fn ⍺⍺ at depths ⍵⍵.
    ⍺←⊣
    depths←⌽3⍴⌽⍵⍵                       ⍝ expand right operand
    m l rdepths-⍨(|≡¨⍵ ⍺ ⍵)×depths≥0   ⍝ ¨ digs top-down
    max encl←'¨⊂'⍴¨⍨l(⌈,∘|-)r           ⍝ find number of ¨s and ⊂s
    el er(1 0=lr)/¨⊂encl              ⍝ where do the ⊂s go?
    0::⎕SIGNAL ⎕EN                      ⍝ bubble errors up
    ⍎'(',el,'⍺)⍺⍺',max,er,'⍵'           ⍝ do it!
}
code_colours

test script

Back to: notes

Back to: Workspaces