Skip to content

set

a collection with no repeats and no order

1
# set
2
set(1, 2, 3)
3
# from values
4
set(1, 2, 2)set(1, 2)
Example outputCtrl+Enter to run
1
# | & - combine sets
2
set(1, 2) | set(2, 3)set(1, 2, 3)
Example outputCtrl+Enter to run
  • list convert to a list: a string’s characters, a map’s [key, value] pairs, a set’s items, a table’s rows as maps, or a copy of a list
  • len how many items a list, map or set has, characters a string has, or bytes a bytes value has
  • contains whether x is in v: text (or a regex match) in a string, an item in a list or set, or a key in a map
  • sort a sorted copy, smallest first
  • sort_desc a sorted copy, largest first, with the function working as in sort
  • set a set of a list’s items or a string’s characters, or of all the arguments, with repeats dropped
  • power_set every set that can be made from some of s’s items, including the empty set and s itself, smallest first
  • cartesian every pair [x, y] with x from a and y from b
  • is_subset whether every item of a is also in b
  • is_superset whether a has every item of b
  • is_disjoint whether a and b have no items in common
  • add add v to the set, changing it, and return the set
  • remove remove v from the set if it’s there, changing it, and return the set

Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.