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.Date.html | 1049 ++++++++++++++ Data/Libraries/Penlight/docs/classes/pl.List.html | 1443 ++++++++++++++++++++ Data/Libraries/Penlight/docs/classes/pl.Map.html | 454 ++++++ .../Penlight/docs/classes/pl.MultiMap.html | 207 +++ .../Penlight/docs/classes/pl.OrderedMap.html | 417 ++++++ Data/Libraries/Penlight/docs/classes/pl.Set.html | 655 +++++++++ 6 files changed, 4225 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/classes/pl.Date.html create mode 100644 Data/Libraries/Penlight/docs/classes/pl.List.html create mode 100644 Data/Libraries/Penlight/docs/classes/pl.Map.html create mode 100644 Data/Libraries/Penlight/docs/classes/pl.MultiMap.html create mode 100644 Data/Libraries/Penlight/docs/classes/pl.OrderedMap.html create mode 100644 Data/Libraries/Penlight/docs/classes/pl.Set.html (limited to 'Data/Libraries/Penlight/docs/classes') diff --git a/Data/Libraries/Penlight/docs/classes/pl.Date.html b/Data/Libraries/Penlight/docs/classes/pl.Date.html new file mode 100644 index 0000000..47d3d65 --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.Date.html @@ -0,0 +1,1049 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.Date

+

Date and Date Format classes.

+

See the Guide.

+ +

NOTE: the date module is deprecated! see + https://github.com/lunarmodules/Penlight/issues/285

+ +

Dependencies: pl.class, pl.stringx, pl.utils

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date:set (t)set the current time of this Date object.
Date.tzone (ts)get the time zone offset from UTC.
Date:toUTC ()convert this date to UTC.
Date:toLocal ()convert this UTC date to local.
Date:year (y)set the year.
Date:month (m)set the month.
Date:day (d)set the day.
Date:hour (h)set the hour.
Date:min (min)set the minutes.
Date:sec (sec)set the seconds.
Date:yday (yday)set the day of year.
Date:year (y)get the year.
Date:month ()get the month.
Date:day ()get the day.
Date:hour ()get the hour.
Date:min ()get the minutes.
Date:sec ()get the seconds.
Date:yday ()get the day of year.
Date:weekday_name (full)name of day of week.
Date:month_name (full)name of month.
Date:is_weekend ()is this day on a weekend?.
Date:add (t)add to a date object.
Date:last_day ()last day of the month.
Date:diff (other)difference between two Date objects.
Date:__tostring ()long numerical ISO data format version of this date.
Date:__eq (other)equality between Date objects.
Date:__lt (other)ordering between Date objects.
Date:__sub ()difference between Date objects.
Date:__add (other)add a date and an interval.
Date.Interval (t)Date.Interval constructor
Date.Interval:__tostring ()If it's an interval then the format is '2 hours 29 sec' etc.
Date.Format (fmt.)Date.Format constructor.
Date.Format:parse (str)parse a string into a Date object.
Date.Format:tostring (d)convert a Date object into a string.
Date.Format:US_order (yesno)force US order in dates like 9/11/2001
+

Methods

+ + + + + +
pl.Date:Date (t, ...)Date constructor.
+ +
+
+ + +

Functions

+ +
+
+ + Date:set (t) +
+
+ set the current time of this Date object. + + +

Parameters:

+
    +
  • t + int + seconds since epoch +
  • +
+ + + + + +
+
+ + Date.tzone (ts) +
+
+ get the time zone offset from UTC. + + +

Parameters:

+
    +
  • ts + int + seconds ahead of UTC +
  • +
+ + + + + +
+
+ + Date:toUTC () +
+
+ convert this date to UTC. + + + + + + + +
+
+ + Date:toLocal () +
+
+ convert this UTC date to local. + + + + + + + +
+
+ + Date:year (y) +
+
+ set the year. + + +

Parameters:

+
    +
  • y + int + Four-digit year +
  • +
+ + + + + +
+
+ + Date:month (m) +
+
+ set the month. + + +

Parameters:

+
    +
  • m + int + month +
  • +
+ + + + + +
+
+ + Date:day (d) +
+
+ set the day. + + +

Parameters:

+
    +
  • d + int + day +
  • +
+ + + + + +
+
+ + Date:hour (h) +
+
+ set the hour. + + +

Parameters:

+
    +
  • h + int + hour +
  • +
+ + + + + +
+
+ + Date:min (min) +
+
+ set the minutes. + + +

Parameters:

+
    +
  • min + int + minutes +
  • +
+ + + + + +
+
+ + Date:sec (sec) +
+
+ set the seconds. + + +

Parameters:

+
    +
  • sec + int + seconds +
  • +
+ + + + + +
+
+ + Date:yday (yday) +
+
+ set the day of year. + + +

Parameters:

+
    +
  • yday + int + day of year +
  • +
+ + + + + +
+
+ + Date:year (y) +
+
+ get the year. + + +

Parameters:

+
    +
  • y + int + Four-digit year +
  • +
+ + + + + +
+
+ + Date:month () +
+
+ get the month. + + + + + + + +
+
+ + Date:day () +
+
+ get the day. + + + + + + + +
+
+ + Date:hour () +
+
+ get the hour. + + + + + + + +
+
+ + Date:min () +
+
+ get the minutes. + + + + + + + +
+
+ + Date:sec () +
+
+ get the seconds. + + + + + + + +
+
+ + Date:yday () +
+
+ get the day of year. + + + + + + + +
+
+ + Date:weekday_name (full) +
+
+ name of day of week. + + +

Parameters:

+
    +
  • full + bool + abbreviated if true, full otherwise. +
  • +
+ +

Returns:

+
    + + string + name +
+ + + + +
+
+ + Date:month_name (full) +
+
+ name of month. + + +

Parameters:

+
    +
  • full + int + abbreviated if true, full otherwise. +
  • +
+ +

Returns:

+
    + + string + name +
+ + + + +
+
+ + Date:is_weekend () +
+
+ is this day on a weekend?. + + + + + + + +
+
+ + Date:add (t) +
+
+ add to a date object. + + +

Parameters:

+ + +

Returns:

+
    + + this date +
+ + + + +
+
+ + Date:last_day () +
+
+ last day of the month. + + + +

Returns:

+
    + + int day +
+ + + + +
+
+ + Date:diff (other) +
+
+ difference between two Date objects. + + +

Parameters:

+
    +
  • other + Date + Date object +
  • +
+ +

Returns:

+
    + + Date.Interval + object +
+ + + + +
+
+ + Date:__tostring () +
+
+ long numerical ISO data format version of this date. + + + + + + + +
+
+ + Date:__eq (other) +
+
+ equality between Date objects. + + +

Parameters:

+
    +
  • other + + + +
  • +
+ + + + + +
+
+ + Date:__lt (other) +
+
+ ordering between Date objects. + + +

Parameters:

+
    +
  • other + + + +
  • +
+ + + + + +
+
+ + Date:__sub () +
+
+ difference between Date objects. + + + + + + + +
+
+ + Date:__add (other) +
+
+ add a date and an interval. + + +

Parameters:

+ + + + + + +
+
+ + Date.Interval (t) +
+
+ Date.Interval constructor + + +

Parameters:

+
    +
  • t + int + an interval in seconds +
  • +
+ + + + + +
+
+ + Date.Interval:__tostring () +
+
+ If it's an interval then the format is '2 hours 29 sec' etc. + + + + + + + +
+
+ + Date.Format (fmt.) +
+
+ Date.Format constructor. + + +

Parameters:

+
    +
  • fmt. + string + A string where the following fields are significant:

    + +
      +
    • d day (either d or dd)
    • +
    • y year (either yy or yyy)
    • +
    • m month (either m or mm)
    • +
    • H hour (either H or HH)
    • +
    • M minute (either M or MM)
    • +
    • S second (either S or SS)
    • +
    + +

    Alternatively, if fmt is nil then this returns a flexible date parser + that tries various date/time schemes in turn:

    + +
      +
    • ISO 8601, like 2010-05-10 12:35:23Z or 2008-10-03T14:30+02
    • +
    • times like 15:30 or 8.05pm (assumed to be today's date)
    • +
    • dates like 28/10/02 (European order!) or 5 Feb 2012
    • +
    • month name like march or Mar (case-insensitive, first 3 letters); here the + day will be 1 and the year this current year
    • +
    + +

    A date in format 3 can be optionally followed by a time in format 2. + Please see test-date.lua in the tests folder for more examples. +

  • +
+ + + + +

Usage:

+
    +
    df = Date.Format("yyyy-mm-dd HH:MM:SS")
    +
+ +
+
+ + Date.Format:parse (str) +
+
+ parse a string into a Date object. + + +

Parameters:

+
    +
  • str + string + a date string +
  • +
+ +

Returns:

+
    + + date object +
+ + + + +
+
+ + Date.Format:tostring (d) +
+
+ convert a Date object into a string. + + +

Parameters:

+
    +
  • d + a date object, or a time value as returned by os.time +
  • +
+ +

Returns:

+
    + + string +
+ + + + +
+
+ + Date.Format:US_order (yesno) +
+
+ force US order in dates like 9/11/2001 + + +

Parameters:

+
    +
  • yesno + + + +
  • +
+ + + + + +
+
+

Methods

+ +
+
+ + pl.Date:Date (t, ...) +
+
+ Date constructor. + + +

Parameters:

+
    +
  • t + +

    this can be either

    + +
      +
    • nil or empty - use current date and time
    • +
    • number - seconds since epoch (as returned by os.time). Resulting time is UTC
    • +
    • Date - make a copy of this date
    • +
    • table - table containing year, month, etc as for os.time. You may leave out year, month or day, + in which case current values will be used.
    • +
    • year (will be followed by month, day etc)
    • +
    + + +
  • +
  • ... + true if Universal Coordinated Time, or two to five numbers: month,day,hour,min,sec +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/classes/pl.List.html b/Data/Libraries/Penlight/docs/classes/pl.List.html new file mode 100644 index 0000000..b84209f --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.List.html @@ -0,0 +1,1443 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.List

+

Python-style list class.

+

Please Note: methods that change the list will return the list. + This is to allow for method chaining, but please note that ls = ls:sort() + does not mean that a new copy of the list is made. In-place (mutable) methods + are marked as returning 'the list' in this documentation.

+ +

See the Guide for further discussion

+ +

See http://www.python.org/doc/current/tut/tut.html, section 5.1

+ +

Note: The comments before some of the functions are from the Python docs + and contain Python code.

+ +

Written for Lua version Nick Trout 4.0; Redone for Lua 5.1, Steve Donovan.

+ +

Dependencies: pl.utils, pl.tablex, pl.class

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
List.new ([t])Create a new list.
List:clone ()Make a copy of an existing list.
List:append (i)Add an item to the end of the list.
List:extend (L)Extend the list by appending all the items in the given list.
List:insert (i, x)Insert an item at a given position.
List:put (x)Insert an item at the begining of the list.
List:remove (i)Remove an element given its index.
List:remove_value (x)Remove the first item from the list whose value is given.
List:pop ([i])Remove the item at the given position in the list, and return it.
List:index (x[, idx=1])Return the index in the list of the first item whose value is given.
List:contains (x)Does this list contain the value?
List:count (x)Return the number of times value appears in the list.
List:sort ([cmp='<'])Sort the items of the list, in place.
List:sorted ([cmp='<'])Return a sorted copy of this list.
List:reverse ()Reverse the elements of the list, in place.
List:minmax ()Return the minimum and the maximum value of the list.
List:slice (first, last)Emulate list slicing.
List:clear ()Empty the list.
List.range (start[, finish[, incr=1]])Emulate Python's range(x) function.
List:len ()list:len() is the same as #list.
List:chop (i1, i2)Remove a subrange of elements.
List:splice (idx, list)Insert a sublist into a list + equivalent to 's[idx:idx] = list' in Python
List:slice_assign (i1, i2, seq)General slice assignment s[i1:i2] = seq.
List:join ([delim=''])Join the elements of a list using a delimiter.
List:concat ([delim=''])Join a list of strings.
List:foreach (fun, ...)Call the function on each element of the list.
List:foreachm (name, ...)Call the named method on each element of the list.
List:filter (fun[, arg])Create a list of all elements which match a function.
List.split (s[, delim])Split a string using a delimiter.
List:map (fun, ...)Apply a function to all elements.
List:transform (fun, ...)Apply a function to all elements, in-place.
List:map2 (fun, ls, ...)Apply a function to elements of two lists.
List:mapm (name, ...)apply a named method to all elements.
List:reduce (fun)'reduce' a list using a binary function.
List:partition (fun, ...)Partition a list using a classifier function.
List:iter ()return an iterator over all values.
List.iterate (seq)Create an iterator over a seqence.
+

metamethods

+ + + + + + + + + + + + + +
List:__concat (L)Concatenation operator.
List:__eq (L)Equality operator ==.
List:__tostring ()How our list should be rendered as a string.
+ +
+
+ + +

Functions

+ +
+
+ + List.new ([t]) +
+
+ Create a new list. Can optionally pass a table; + passing another instance of List will cause a copy to be created; + this will return a plain table with an appropriate metatable. + we pass anything which isn't a simple table to iterate() to work out + an appropriate iterator + + +

Parameters:

+
    +
  • t + An optional list-like table + (optional) +
  • +
+ +

Returns:

+
    + + a new List +
+ + +

See also:

+ + +

Usage:

+
    +
    ls = List();  ls = List {1,2,3,4}
    +
+ +
+
+ + List:clone () +
+
+ Make a copy of an existing list. + The difference from a plain 'copy constructor' is that this returns + the actual List subtype. + + + + + + + +
+
+ + List:append (i) +
+
+ Add an item to the end of the list. + + +

Parameters:

+
    +
  • i + An item +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:extend (L) +
+
+ Extend the list by appending all the items in the given list. + equivalent to 'a[len(a):] = L'. + + +

Parameters:

+
    +
  • L + List + Another List +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:insert (i, x) +
+
+ Insert an item at a given position. i is the index of the + element before which to insert. + + +

Parameters:

+
    +
  • i + int + index of element before whichh to insert +
  • +
  • x + A data item +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:put (x) +
+
+ Insert an item at the begining of the list. + + +

Parameters:

+
    +
  • x + a data item +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:remove (i) +
+
+ Remove an element given its index. + (equivalent of Python's del s[i]) + + +

Parameters:

+
    +
  • i + int + the index +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:remove_value (x) +
+
+ Remove the first item from the list whose value is given. + (This is called 'remove' in Python; renamed to avoid confusion + with table.remove) + Return nil if there is no such item. + + +

Parameters:

+
    +
  • x + A data value +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:pop ([i]) +
+
+ Remove the item at the given position in the list, and return it. + If no index is specified, a:pop() returns the last item in the list. + The item is also removed from the list. + + +

Parameters:

+
    +
  • i + int + An index + (optional) +
  • +
+ +

Returns:

+
    + + the item +
+ + + + +
+
+ + List:index (x[, idx=1]) +
+
+ Return the index in the list of the first item whose value is given. + Return nil if there is no such item. + + +

Parameters:

+
    +
  • x + A data value +
  • +
  • idx + int + where to start search + (default 1) +
  • +
+ +

Returns:

+
    + + the index, or nil if not found. +
+ + + + +
+
+ + List:contains (x) +
+
+ Does this list contain the value? + + +

Parameters:

+
    +
  • x + A data value +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + List:count (x) +
+
+ Return the number of times value appears in the list. + + +

Parameters:

+
    +
  • x + A data value +
  • +
+ +

Returns:

+
    + + number of times x appears +
+ + + + +
+
+ + List:sort ([cmp='<']) +
+
+ Sort the items of the list, in place. + + +

Parameters:

+
    +
  • cmp + func + an optional comparison function + (default '<') +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:sorted ([cmp='<']) +
+
+ Return a sorted copy of this list. + + +

Parameters:

+
    +
  • cmp + func + an optional comparison function + (default '<') +
  • +
+ +

Returns:

+
    + + a new list +
+ + + + +
+
+ + List:reverse () +
+
+ Reverse the elements of the list, in place. + + + +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:minmax () +
+
+ Return the minimum and the maximum value of the list. + + + +

Returns:

+
    +
  1. + minimum value
  2. +
  3. + maximum value
  4. +
+ + + + +
+
+ + List:slice (first, last) +
+
+ Emulate list slicing. like 'list[first:last]' in Python. + If first or last are negative then they are relative to the end of the list + eg. slice(-2) gives last 2 entries in a list, and + slice(-4,-2) gives from -4th to -2nd + + +

Parameters:

+
    +
  • first + An index +
  • +
  • last + An index +
  • +
+ +

Returns:

+
    + + a new List +
+ + + + +
+
+ + List:clear () +
+
+ Empty the list. + + + +

Returns:

+
    + + the list +
+ + + + +
+
+ + List.range (start[, finish[, incr=1]]) +
+
+ Emulate Python's range(x) function. + Include it in List table for tidiness + + +

Parameters:

+
    +
  • start + int + A number +
  • +
  • finish + int + A number greater than start; if absent, + then start is 1 and finish is start + (optional) +
  • +
  • incr + int + an increment (may be less than 1) + (default 1) +
  • +
+ +

Returns:

+
    + + a List from start .. finish +
+ + + +

Usage:

+
    +
  • List.range(0,3) == List{0,1,2,3}
  • +
  • List.range(4) = List{1,2,3,4}
  • +
  • List.range(5,1,-1) == List{5,4,3,2,1}
  • +
+ +
+
+ + List:len () +
+
+ list:len() is the same as #list. + + + + + + + +
+
+ + List:chop (i1, i2) +
+
+ Remove a subrange of elements. + equivalent to 'del s[i1:i2]' in Python. + + +

Parameters:

+
    +
  • i1 + int + start of range +
  • +
  • i2 + int + end of range +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:splice (idx, list) +
+
+ Insert a sublist into a list + equivalent to 's[idx:idx] = list' in Python + + +

Parameters:

+
    +
  • idx + int + index +
  • +
  • list + List + list to insert +
  • +
+ +

Returns:

+
    + + the list +
+ + + +

Usage:

+
    +
    l = List{10,20}; l:splice(2,{21,22});  assert(l == List{10,21,22,20})
    +
+ +
+
+ + List:slice_assign (i1, i2, seq) +
+
+ General slice assignment s[i1:i2] = seq. + + +

Parameters:

+
    +
  • i1 + int + start index +
  • +
  • i2 + int + end index +
  • +
  • seq + List + a list +
  • +
+ +

Returns:

+
    + + the list +
+ + + + +
+
+ + List:join ([delim='']) +
+
+ Join the elements of a list using a delimiter. + This method uses tostring on all elements. + + +

Parameters:

+
    +
  • delim + string + a delimiter string, can be empty. + (default '') +
  • +
+ +

Returns:

+
    + + a string +
+ + + + +
+
+ + List:concat ([delim='']) +
+
+ Join a list of strings.
+ Uses table.concat directly. + + +

Parameters:

+
    +
  • delim + string + a delimiter + (default '') +
  • +
+ +

Returns:

+
    + + a string +
+ + + + +
+
+ + List:foreach (fun, ...) +
+
+ Call the function on each element of the list. + + +

Parameters:

+
    +
  • fun + func + a function or callable object +
  • +
  • ... + optional values to pass to function +
  • +
+ + + + + +
+
+ + List:foreachm (name, ...) +
+
+ Call the named method on each element of the list. + + +

Parameters:

+
    +
  • name + string + the method name +
  • +
  • ... + optional values to pass to function +
  • +
+ + + + + +
+
+ + List:filter (fun[, arg]) +
+
+ Create a list of all elements which match a function. + + +

Parameters:

+
    +
  • fun + func + a boolean function +
  • +
  • arg + optional argument to be passed as second argument of the predicate + (optional) +
  • +
+ +

Returns:

+
    + + a new filtered list. +
+ + + + +
+
+ + List.split (s[, delim]) +
+
+ Split a string using a delimiter. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • delim + string + the delimiter (default spaces) + (optional) +
  • +
+ +

Returns:

+
    + + a List of strings +
+ + +

See also:

+ + + +
+
+ + List:map (fun, ...) +
+
+ Apply a function to all elements. + Any extra arguments will be passed to the function. + + +

Parameters:

+
    +
  • fun + func + a function of at least one argument +
  • +
  • ... + arbitrary extra arguments. +
  • +
+ +

Returns:

+
    + + a new list: {f(x) for x in self} +
+ + +

See also:

+ + +

Usage:

+
    +
    List{'one','two'}:map(string.upper) == {'ONE','TWO'}
    +
+ +
+
+ + List:transform (fun, ...) +
+
+ Apply a function to all elements, in-place. + Any extra arguments are passed to the function. + + +

Parameters:

+
    +
  • fun + func + A function that takes at least one argument +
  • +
  • ... + arbitrary extra arguments. +
  • +
+ +

Returns:

+
    + + the list. +
+ + + + +
+
+ + List:map2 (fun, ls, ...) +
+
+ Apply a function to elements of two lists. + Any extra arguments will be passed to the function + + +

Parameters:

+
    +
  • fun + func + a function of at least two arguments +
  • +
  • ls + List + another list +
  • +
  • ... + arbitrary extra arguments. +
  • +
+ +

Returns:

+
    + + a new list: {f(x,y) for x in self, for x in arg1} +
+ + +

See also:

+ + + +
+
+ + List:mapm (name, ...) +
+
+ apply a named method to all elements. + Any extra arguments will be passed to the method. + + +

Parameters:

+
    +
  • name + string + name of method +
  • +
  • ... + extra arguments +
  • +
+ +

Returns:

+
    + + a new list of the results +
+ + +

See also:

+ + + +
+
+ + List:reduce (fun) +
+
+ 'reduce' a list using a binary function. + + +

Parameters:

+
    +
  • fun + func + a function of two arguments +
  • +
+ +

Returns:

+
    + + result of the function +
+ + +

See also:

+ + + +
+
+ + List:partition (fun, ...) +
+
+ Partition a list using a classifier function. + The function may return nil, but this will be converted to the string key ''. + + +

Parameters:

+
    +
  • fun + func + a function of at least one argument +
  • +
  • ... + will also be passed to the function +
  • +
+ +

Returns:

+
    + + MultiMap + a table where the keys are the returned values, and the values are Lists + of values where the function returned that key. +
+ + +

See also:

+ + + +
+
+ + List:iter () +
+
+ return an iterator over all values. + + + + + + + +
+
+ + List.iterate (seq) +
+
+ Create an iterator over a seqence. + This captures the Python concept of 'sequence'. + For tables, iterates over all values with integer indices. + + +

Parameters:

+
    +
  • seq + a sequence; a string (over characters), a table, a file object (over lines) or an iterator function +
  • +
+ + + + +

Usage:

+
    +
  • for x in iterate {1,10,22,55} do io.write(x,',') end ==> 1,10,22,55
  • +
  • for ch in iterate 'help' do do io.write(ch,' ') end ==> h e l p
  • +
+ +
+
+

metamethods

+ +
+
+ + List:__concat (L) +
+
+ Concatenation operator. + + +

Parameters:

+
    +
  • L + List + another List +
  • +
+ +

Returns:

+
    + + a new list consisting of the list with the elements of the new list appended +
+ + + + +
+
+ + List:__eq (L) +
+
+ Equality operator ==. True iff all elements of two lists are equal. + + +

Parameters:

+
    +
  • L + List + another List +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + List:__tostring () +
+
+ How our list should be rendered as a string. Uses join(). + + + + + +

See also:

+ + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/classes/pl.Map.html b/Data/Libraries/Penlight/docs/classes/pl.Map.html new file mode 100644 index 0000000..72b4b40 --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.Map.html @@ -0,0 +1,454 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.Map

+

A Map class.

+

+ + + +

+> Map = require 'pl.Map'
+> m = Map{one=1,two=2}
+> m:update {three=3,four=4,two=20}
+> = m == M{one=1,two=20,three=3,four=4}
+true
+
+ +

Dependencies: pl.utils, pl.class, pl.tablex, pl.pretty

+

+ + +

Fields

+ + + + + + + + + +
pl.Map.keyslist of keys.
pl.Map.valueslist of values.
+

Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pl.Map:iter ()return an iterator over all key-value pairs.
pl.Map:items ()return a List of all key-value pairs, sorted by the keys.
pl.Map:setdefault (key, default)set a value in the map if it doesn't exist yet.
pl.Map:len ()size of map.
pl.Map:set (key, val)put a value into the map.
pl.Map:get (key)get a value from the map.
pl.Map:getvalues (keys)get a list of values indexed by a list of keys.
pl.Map:update (table)update the map using key/value pairs from another table.
+

Metamethods

+ + + + + + + + + +
pl.Map:__eq (m)equality between maps.
pl.Map:__tostring ()string representation of a map.
+ +
+
+ + +

Fields

+ +
+
+ + pl.Map.keys +
+
+ list of keys. + + + + + + + +
+
+ + pl.Map.values +
+
+ list of values. + + + + + + + +
+
+

Methods

+ +
+
+ + pl.Map:iter () +
+
+ return an iterator over all key-value pairs. + + + + + + + +
+
+ + pl.Map:items () +
+
+ return a List of all key-value pairs, sorted by the keys. + + + + + + + +
+
+ + pl.Map:setdefault (key, default) +
+
+ set a value in the map if it doesn't exist yet. + + +

Parameters:

+
    +
  • key + the key +
  • +
  • default + value to set +
  • +
+ +

Returns:

+
    + + the value stored in the map (existing value, or the new value) +
+ + + + +
+
+ + pl.Map:len () +
+
+ size of map. + note: this is a relatively expensive operation! + + + + + + + +
+
+ + pl.Map:set (key, val) +
+
+ put a value into the map. + This will remove the key if the value is nil + + +

Parameters:

+
    +
  • key + the key +
  • +
  • val + the value +
  • +
+ + + + + +
+
+ + pl.Map:get (key) +
+
+ get a value from the map. + + +

Parameters:

+
    +
  • key + the key +
  • +
+ +

Returns:

+
    + + the value, or nil if not found. +
+ + + + +
+
+ + pl.Map:getvalues (keys) +
+
+ get a list of values indexed by a list of keys. + + +

Parameters:

+
    +
  • keys + a list-like table of keys +
  • +
+ +

Returns:

+
    + + a new list +
+ + + + +
+
+ + pl.Map:update (table) +
+
+ update the map using key/value pairs from another table. + + +

Parameters:

+
    +
  • table + tab + + + +
  • +
+ + + + + +
+
+

Metamethods

+ +
+
+ + pl.Map:__eq (m) +
+
+ equality between maps. + + +

Parameters:

+
    +
  • m + Map + another map. +
  • +
+ + + + + +
+
+ + pl.Map:__tostring () +
+
+ string representation of a map. + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/classes/pl.MultiMap.html b/Data/Libraries/Penlight/docs/classes/pl.MultiMap.html new file mode 100644 index 0000000..b711b54 --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.MultiMap.html @@ -0,0 +1,207 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.MultiMap

+

MultiMap, a Map which has multiple values per key.

+

Dependencies: pl.utils, pl.class, pl.List, pl.Map

+ + +

Methods

+ + + + + + + + + +
pl.MultiMap:update (t)update a MultiMap using a table.
pl.MultiMap:set (key, val)add a new value to a key.
+ +
+
+ + +

Methods

+ +
+
+ + pl.MultiMap:update (t) +
+
+ update a MultiMap using a table. + + +

Parameters:

+
    +
  • t + either a Multimap or a map-like table. +
  • +
+ +

Returns:

+
    + + the map +
+ + + + +
+
+ + pl.MultiMap:set (key, val) +
+
+ add a new value to a key. Setting a nil value removes the key. + + +

Parameters:

+
    +
  • key + the key +
  • +
  • val + the value +
  • +
+ +

Returns:

+
    + + the map +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/classes/pl.OrderedMap.html b/Data/Libraries/Penlight/docs/classes/pl.OrderedMap.html new file mode 100644 index 0000000..537af37 --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.OrderedMap.html @@ -0,0 +1,417 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.OrderedMap

+

OrderedMap, a map which preserves ordering.

+

Derived from pl.Map.

+ +

Dependencies: pl.utils, pl.tablex, pl.class, pl.List, pl.Map

+ + +

Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pl.OrderedMap:_init (t)construct an OrderedMap.
pl.OrderedMap:update (t)update an OrderedMap using a table.
pl.OrderedMap:set (key, val)set the key's value.
pl.OrderedMap:insert (pos, key, val)insert a key/value pair before a given position.
pl.OrderedMap:keys ()return the keys in order.
pl.OrderedMap:values ()return the values in order.
pl.OrderedMap:sort (cmp)sort the keys.
pl.OrderedMap:iter ()iterate over key-value pairs in order.
+

Metamethods

+ + + + + + + + + +
pl.OrderedMap:__pairs ()iterate over an ordered map (5.2).
pl.OrderedMap:__tostring ()string representation of an ordered map.
+ +
+
+ + +

Methods

+ +
+
+ + pl.OrderedMap:_init (t) +
+
+ construct an OrderedMap. + Will throw an error if the argument is bad. + + +

Parameters:

+ + + + + + +
+
+ + pl.OrderedMap:update (t) +
+
+ update an OrderedMap using a table. + If the table is itself an OrderedMap, then its entries will be appended. + if it s a table of the form {{key1=val1},{key2=val2},...} these will be appended.

+ +

Otherwise, it is assumed to be a map-like table, and order of extra entries is arbitrary. + + +

Parameters:

+
    +
  • t + tab + a table. +
  • +
+ +

Returns:

+
    +
  1. + the map, or nil in case of error
  2. +
  3. + the error message
  4. +
+ + + + +
+
+ + pl.OrderedMap:set (key, val) +
+
+ set the key's value. This key will be appended at the end of the map.

+ +

If the value is nil, then the key is removed. + + +

Parameters:

+
    +
  • key + the key +
  • +
  • val + the value +
  • +
+ +

Returns:

+
    + + the map +
+ + + + +
+
+ + pl.OrderedMap:insert (pos, key, val) +
+
+ insert a key/value pair before a given position. + Note: if the map already contains the key, then this effectively + moves the item to the new position by first removing at the old position. + Has no effect if the key does not exist and val is nil + + +

Parameters:

+
    +
  • pos + int + a position starting at 1 +
  • +
  • key + the key +
  • +
  • val + the value; if nil use the old value +
  • +
+ + + + + +
+
+ + pl.OrderedMap:keys () +
+
+ return the keys in order. + (Not a copy!) + + + +

Returns:

+
    + + List +
+ + + + +
+
+ + pl.OrderedMap:values () +
+
+ return the values in order. + this is relatively expensive. + + + +

Returns:

+
    + + List +
+ + + + +
+
+ + pl.OrderedMap:sort (cmp) +
+
+ sort the keys. + + +

Parameters:

+
    +
  • cmp + func + a comparison function as for table.sort +
  • +
+ +

Returns:

+
    + + the map +
+ + + + +
+
+ + pl.OrderedMap:iter () +
+
+ iterate over key-value pairs in order. + + + + + + + +
+
+

Metamethods

+ +
+
+ + pl.OrderedMap:__pairs () +
+
+ iterate over an ordered map (5.2). + + + + + + + +
+
+ + pl.OrderedMap:__tostring () +
+
+ string representation of an ordered map. + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + 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