wrap←{⎕IO←0                     ⍝ Wrap word vector at ⍺ cols.
    ⍺←⎕PW                       ⍝ default ⎕PW-wrap.
    ⍺≥⍴⍵:⍵                      ⍝ short enough vector: finished.
    gaps←⍸' '=(⍺+1)↑⍵           ⍝ indices of blanks.
    take←¯1↑⍺,(⍺≥gaps)/gaps     ⍝ chars to take.
    droptake+' '=take⊃⍵        ⍝ chars to drop.
    head(take↑⍵),⎕UCS 13       ⍝ first line and <LF> then,
    head,⍺ ∇ drop↓⍵             ⍝ wrapped following lines.
}
code_colours

test script

Back to: notes

Back to: Workspaces