From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- Data/Libraries/Penlight/docs/classes/pl.Set.html | 655 +++++++++++++++++++++++ 1 file changed, 655 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/classes/pl.Set.html (limited to 'Data/Libraries/Penlight/docs/classes/pl.Set.html') diff --git a/Data/Libraries/Penlight/docs/classes/pl.Set.html b/Data/Libraries/Penlight/docs/classes/pl.Set.html new file mode 100644 index 0000000..31cfcee --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.Set.html @@ -0,0 +1,655 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.Set

+

A Set class.

+

+ + + +

+> Set = require 'pl.Set'
+> = Set{'one','two'} == Set{'two','one'}
+true
+> fruit = Set{'apple','banana','orange'}
+> = fruit['banana']
+true
+> = fruit['hazelnut']
+nil
+> colours = Set{'red','orange','green','blue'}
+> = fruit,colours
+[apple,orange,banana]   [blue,green,orange,red]
+> = fruit+colours
+[blue,green,apple,red,orange,banana]
+[orange]
+> more_fruits = fruit + 'apricot'
+> = fruit*colours
+ =  more_fruits, fruit
+banana,apricot,apple,orange]    [banana,apple,orange]
+
+ +

Dependencies: pl.utils, pl.tablex, pl.class, pl.Map, (pl.List if __tostring is used)

+

+ + +

Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pl.Set:Set (t)create a set.
pl.Set:values (self)get a list of the values in a set.
pl.Set:map (self, fn, ...)map a function over the values of a set.
pl.Set:union (self, set)union of two sets (also +).
pl.Set:intersection (self, set)intersection of two sets (also *).
pl.Set:difference (self, set)new set with elements in the set that are not in the other (also -).
pl.Set:issubset (self, set)is the first set a subset of the second (also <)?.
pl.Set:isempty (self)is the set empty?.
pl.Set:isdisjoint (s1, s2)are the sets disjoint?
pl.Set:len (s)size of this set (also # for 5.2).
+

Metamethods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pl.Set:__tostring ()string representation of a set.
pl.Set:__add ()union of sets.
pl.Set:__mul ()intersection of sets.
pl.Set:__sub ()difference of sets.
pl.Set:__pow ()symmetric difference of sets.
pl.Set:__lt ()first set subset of second?
pl.Set:__len ()cardinality of set (5.2).
pl.Set:__eq (s1, s2)equality between sets.
+ +
+
+ + +

Methods

+ +
+
+ + pl.Set:Set (t) +
+
+ create a set.
+ + +

Parameters:

+
    +
  • t + may be a Set, Map or list-like table. +
  • +
+ + + + + +
+
+ + pl.Set:values (self) +
+
+ get a list of the values in a set. + + +

Parameters:

+
    +
  • self + a Set +
  • +
+ +

Returns:

+
    + + a list +
+ + + + +
+
+ + pl.Set:map (self, fn, ...) +
+
+ map a function over the values of a set. + + +

Parameters:

+
    +
  • self + a Set +
  • +
  • fn + a function +
  • +
  • ... + extra arguments to pass to the function. +
  • +
+ +

Returns:

+
    + + a new set +
+ + + + +
+
+ + pl.Set:union (self, set) +
+
+ union of two sets (also +). + + +

Parameters:

+
    +
  • self + a Set +
  • +
  • set + another set +
  • +
+ +

Returns:

+
    + + a new set +
+ + + + +
+
+ + pl.Set:intersection (self, set) +
+
+ intersection of two sets (also *). + + +

Parameters:

+
    +
  • self + a Set +
  • +
  • set + another set +
  • +
+ +

Returns:

+
    + + a new set +
+ + + +

Usage:

+
    +
    > s = Set{10,20,30}
    +> t = Set{20,30,40}
    +> = t
    +[20,30,40]
    +> = Set.intersection(s,t)
    +[30,20]
    +> = s*t
    +[30,20]
    +
+ +
+
+ + pl.Set:difference (self, set) +
+
+ new set with elements in the set that are not in the other (also -). + + +

Parameters:

+
    +
  • self + a Set +
  • +
  • set + another set +
  • +
+ +

Returns:

+
    + + a new set +
+ + + + +
+
+ + pl.Set:issubset (self, set) +
+
+ is the first set a subset of the second (also <)?. + + +

Parameters:

+
    +
  • self + a Set +
  • +
  • set + another set +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + pl.Set:isempty (self) +
+
+ is the set empty?. + + +

Parameters:

+
    +
  • self + a Set +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + pl.Set:isdisjoint (s1, s2) +
+
+ are the sets disjoint? (no elements in common). + Uses naive definition, i.e. that intersection is empty + + +

Parameters:

+
    +
  • s1 + a Set +
  • +
  • s2 + another set +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + pl.Set:len (s) +
+
+ size of this set (also # for 5.2). + + +

Parameters:

+
    +
  • s + a Set +
  • +
+ +

Returns:

+
    + + size +
+ + + + +
+
+

Metamethods

+ +
+
+ + pl.Set:__tostring () +
+
+ string representation of a set. + + + + + + + +
+
+ + pl.Set:__add () +
+
+ union of sets. + + + + + + + +
+
+ + pl.Set:__mul () +
+
+ intersection of sets. + + + + + + + +
+
+ + pl.Set:__sub () +
+
+ difference of sets. + + + + + + + +
+
+ + pl.Set:__pow () +
+
+ symmetric difference of sets. + + + + + + + +
+
+ + pl.Set:__lt () +
+
+ first set subset of second? + + + + + + + +
+
+ + pl.Set:__len () +
+
+ cardinality of set (5.2). + + + + + + + +
+
+ + pl.Set:__eq (s1, s2) +
+
+ equality between sets. + + +

Parameters:

+
    +
  • s1 + + + +
  • +
  • s2 + + + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0