wiki:LibraryList

List methods

Operators

  • +/or: takes the union of both lists (with coercion to list if necessary)
  • and: takes the intersection of both lists
  • /: takes all elements in the first list that aren't in the second list

Methods

  • decide: given an array with an even number of elements (with odd elements containing a boolean value or an expression that evaluates to boolean), return the even element that corresponds to the first true value seen. If that element is a code object, it runs that object. Example:
var i = 3;
[i < 3, { "i is less than 3"|print; },
 i > 3, { "i is greater than 3"|print; },
 i == 3, { "i is equal to 3"|print; }]|decide;

decide returns false if none of the conditions are true.

  • string: coerces the list to string
  • print: outputs the string value of the list to standard output.
  • sum: outputs the sum of every number in the list
  • product: outputs the product of every number in the list (i.e. element 1 * element 2 * ...)
  • length: returns number of elements in list