Synopsis Library functions for sets.
Usage import Set;
Description For operators on sets see Values/Set.

The following functions are defined for sets:
  • classify: Classify elements in a set.
  • getOneFrom: Pick a random element from a set.
  • group: Group elements in a set given an equivalence function.
  • index: Map set elements to a fixed index.
  • isEmpty: Test whether a set is empty.
  • itoString: Convert a set to an indented string.
  • mapper: Apply a function to all set elements and return set of results.
  • max: Determine the largest element of a set.
  • min: Smallest element of a set.
  • power: Determine the powerset of a set.
  • power1: The powerset (excluding the empty set) of a set value.
  • reducer: Apply a function to successive elements of a set and combine the results (deprecated).
  • size: Determine the number of elements in a set.
  • sort: Sort the elements of a set. Sort the elements of a set: # Use the built-in ordering on values to compare list elements. # Give an additional lessThan function that will be used to compare elements. This function lessThan (<) function should implement a strict partial order, meaning: # that it is not reflexive, i.e. never a < a # is anti-symmetric, i.e. never a < b && b < a. # is transitive, i.e. if a < b and b < c then a < c.
  • sum: Sum the elements of a set.
  • takeOneFrom: Remove an arbitrary element from a set, returns the element and a set without that element.
  • toList: Convert a set to a list.
  • toMap: Convert a set of tuples to a map; each key is associated with a set of values.
  • toMapUnique: Convert a set of tuples to a map (provided that there are no multiple keys).
  • toString: Convert a set to a string.
  • union: flatten a set of sets into a single set.
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit