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

code_colours

test script

Back to: notes

Back to: Workspaces