Method code for $list.swap()

[Turn off line numbering]
  1: arg list, a, b;
  2: var holder;
  3: 
  4: // swap elements at indexes a and b
  5: if (listlen(list) < a || listlen(list) < b || a < 1 || b < 1)
  6:     throw(~args, "Index specifiers are outside the range of the list.");
  7: anticipate_assignment();
  8: holder = list[a];
  9: list = replace(list, a, list[b]);
 10: list = replace(list, b, holder);
 11: return list;

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

Tlon