Module pl.class

Wrapper classes: Map and Set.

Functions

Map:get (key) get a value from the map.
Map:iter () return an iterator over all key-value pairs.
Map:keys () list of keys.
Map:len () size of map.
Map:set (key, val) put a value into the map.
Map:values () list of values.
Set:difference (set) new set with elements in the set that are not in the other (also -).
Set:intersection (set) intersection of two sets (also *).
Set:isdisjoint (set) are the sets disjoint? (no elements in common).
Set:issempty () is the set empty?.
Set:issubset (set) is the first set a subset of the second?.
Set:map (fn, ...) map a function over the values of a set.
Set:set (key) add a value to a set.
Set:union (set) union of two sets (also +).
Set:unset (key) remove a value from a set.
Set:values () get a list of the values in a set.
class (base, c_arg, c) create a new class, derived from a given base class.


Functions

Map:get (key)
get a value from the map.

Parameters:

  • key: the key

Return value:

    the value, or nil if not found.
Map:iter ()
return an iterator over all key-value pairs.
Map:keys ()
list of keys.
Map:len ()
size of map. note: this is a relatively expensive operation!
Map:set (key, val)
put a value into the map.

Parameters:

  • key: the key
  • val: the value
Map:values ()
list of values.
Set:difference (set)
new set with elements in the set that are not in the other (also -).

Parameters:

  • set: another set

Return value:

    a new set
Set:intersection (set)
intersection of two sets (also *).

Parameters:

  • set: another set

Return value:

    a new set
Set:isdisjoint (set)
are the sets disjoint? (no elements in common). Uses naive definition, i.e. that intersection is empty

Parameters:

  • set: another set

Return value:

    true or false
Set:issempty ()
is the set empty?.

Return value:

    true or false
Set:issubset (set)
is the first set a subset of the second?.

Parameters:

  • set:

Return value:

    true or false
Set:map (fn, ...)
map a function over the values of a set.

Parameters:

  • fn: a function
  • ...: extra arguments to pass to the function.

Return value:

    a new set
Set:set (key)
add a value to a set.

Parameters:

  • key: a value
Set:union (set)
union of two sets (also +).

Parameters:

  • set: another set

Return value:

    a new set
Set:unset (key)
remove a value from a set.

Parameters:

  • key: a value
Set:values ()
get a list of the values in a set.
class (base, c_arg, c)
create a new class, derived from a given base class. supporting two class creation syntaxes: either 'Name = class()' or'class.Name()'

Parameters:

  • base: optional base class
  • c_arg: optional parameter to class ctor
  • c: optional table to be used as class

Valid XHTML 1.0!