Method code for $list.fold()

[Turn off line numbering]
  1: arg list, object, method, @args;
  2: var i, out;
  3: 
  4: // apply object.method to a current result and the next element, return the
  5: // result
  6: switch (list.length()) {
  7:     case 0:
  8:         return 0;
  9:     case 1:
 10:         return list[1];
 11: }
 12: out = list[1];
 13: for i in (sublist(list, 2, listlen(list) - 1))
 14:     out = object.(method)(out, i, @args);
 15: return out;

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

Tlon