Method code for $list.fold()

[Turn on line numbering]
arg list, object, method, @args;
var i, out;

// apply object.method to a current result and the next element, return the
// result
switch (list.length()) {
    case 0:
        return 0;
    case 1:
        return list[1];
}
out = list[1];
for i in (sublist(list, 2, listlen(list) - 1))
    out = object.(method)(out, i, @args);
return out;

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

the Cold Dark