Method code for $list.lcolumnize()

[Turn off line numbering]
  1: arg list, @args;
  2: var line, part, lines, max, cols, col, width, len, sep;
  3: 
  4: [(len ?= (| sender().linelen() |) || 78), (sep ?= " ")] = args;
  5: lines = [];
  6: line = "";
  7: max = .element_maxlength(list) + sep.length();
  8: cols = len > max ? len / max : 1;
  9: width = len / cols - sep.length();
 10: col = cols;
 11: for part in (list) {
 12:     col = col - 1;
 13:     if (!col) {
 14:         lines = lines + [line + part];
 15:         line = "";
 16:         col = cols;
 17:         continue;
 18:     }
 19:     line = line + part.pad(width);
 20: }
 21: if (line)
 22:     return lines + [line];
 23: return lines;

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

Tlon