Method code for $list.columnize3()

[Turn on line numbering]
arg list, cols, @rest;
var width, lines, line, separator, linelength, x, handled_length, even_length;

// turn [...] into ".   .   ."
// rest[1]==separator; rest[2]==linelength
[(separator ?= "   "), (linelength ?= 78)] = rest;
width = linelength / cols - separator.length();
lines = [];
handled_length = 1;
even_length = list.length() / cols;
while (handled_length < even_length) {
    line = list.subrange(handled_length, cols).mmap('pad, width).join(separator);
    lines += [line];
    handled_length += cols;
    refresh();
}
if (list.length() >= handled_length)
    lines += [list.subrange(handled_length).mmap('pad, width).join(separator)];
return lines;

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon