Method code for $list.columnize3()

[Turn off line numbering]
  1: arg list, cols, @rest;
  2: var width, lines, line, separator, linelength, x, handled_length, even_length;
  3: 
  4: // turn [...] into ".   .   ."
  5: // rest[1]==separator; rest[2]==linelength
  6: [(separator ?= "   "), (linelength ?= 78)] = rest;
  7: width = linelength / cols - separator.length();
  8: lines = [];
  9: handled_length = 1;
 10: even_length = list.length() / cols;
 11: while (handled_length < even_length) {
 12:     line = list.subrange(handled_length, cols).mmap('pad, width).join(separator);
 13:     lines += [line];
 14:     handled_length += cols;
 15:     refresh();
 16: }
 17: if (list.length() >= handled_length)
 18:     lines += [list.subrange(handled_length).mmap('pad, width).join(separator)];
 19: return lines;

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

Tlon