Method code for $list.tabulate()

[Turn on line numbering]
arg list, headers, @rest;
var i, j, t, t1, trim_cols, header_sep, colsizes, len;

if (!list)
    return [];
[(colsizes ?= 0), (trim_cols ?= 0), (header_sep ?= " "), (len ?= 79)] = rest;
if (!headers)
    headers = .make(list.length(), []);
if (type(headers[1]) == 'string)
    headers = map i in (headers) to ([i]);

// Find the column sizes
if (!colsizes) {
    if (trim_cols) {
        t = map i in (list) to (refresh() && i.element_maxlength() + 2);
        t1 = filter i in [1 .. t.length()] where (t[i] > 2);
        t = map i in (t1) to (t[i]);
        list = map i in (t1) to (list[i]);
        headers = map i in (t1) to (headers[i]);
    }
    colsizes = t ? map i in [1 .. headers.length()] to (refresh() && max(t[i], headers[i].element_maxlength() + 2)) : map i in [1 .. list.length()] to (refresh() && max(headers[i].element_maxlength(), list[i].element_maxlength()) + 2);
}
t = map i in (colsizes) to ("%" + i + "l").sum();
t1 = map i in (colsizes) to ("%" + i + "{" + header_sep + "}l").sum();

// Now format the thing...
return map i in (headers.transpose()) to (refresh() && t1.format(@i).pad(len).trim('right)) + map i in (list.transpose()) to (refresh() && t.format(@i).pad(len).trim('right));

// $#Edited: 30 Apr 97 20:02 $list

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark