vtrim←{⎕IO←0 ⍝ Trim trailing blanks from line-vector. lf sp←⎕UCS 13 32 ⍝ linefeed and space characters. 1↓¯1↓{ ⍝ without linefeeds brackets, types←lf sp⍳⍵ ⍝ 0:lf, 1:sp, 2:ch. mask←~1 1⍷types ⍝ mask of non-(duplicate blanks). comp←mask/types ⍝ ignoring duplicate blanks, csl←2 1 0⍷comp ⍝ sequence: ch, sp, ··· sp, lf. lsl←0 1 0⍷comp ⍝ sequence: lf, sp, ··· sp, lf. from←mask\csl∨lsl ⍝ sequence: xx, sp, ··· sp, lf. upto←1 0⍷types ⍝ sequence: ··········· sp, lf. (~¯1⌽≠\from∨upto)/⍵ ⍝ compressed out: <sp, ··· sp>, lf. }lf,⍵,lf ⍝ bracketed with linefeeds chars. } code_colours test script Back to: notes Back to: Workspaces