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/libraries/pl.Set.html | 650 +++++++ Data/Libraries/Penlight/docs/libraries/pl.app.html | 397 ++++ .../Penlight/docs/libraries/pl.array2d.html | 1319 +++++++++++++ .../Penlight/docs/libraries/pl.class.html | 332 ++++ .../Penlight/docs/libraries/pl.compat.html | 580 ++++++ .../Penlight/docs/libraries/pl.comprehension.html | 165 ++ .../Penlight/docs/libraries/pl.config.html | 259 +++ .../Libraries/Penlight/docs/libraries/pl.data.html | 571 ++++++ Data/Libraries/Penlight/docs/libraries/pl.dir.html | 615 ++++++ .../Libraries/Penlight/docs/libraries/pl.file.html | 301 +++ .../Libraries/Penlight/docs/libraries/pl.func.html | 460 +++++ Data/Libraries/Penlight/docs/libraries/pl.html | 139 ++ .../Penlight/docs/libraries/pl.import_into.html | 142 ++ .../Penlight/docs/libraries/pl.input.html | 336 ++++ .../Libraries/Penlight/docs/libraries/pl.lapp.html | 382 ++++ .../Penlight/docs/libraries/pl.lexer.html | 524 ++++++ .../Penlight/docs/libraries/pl.luabalanced.html | 149 ++ .../Penlight/docs/libraries/pl.operator.html | 819 ++++++++ .../Libraries/Penlight/docs/libraries/pl.path.html | 1070 +++++++++++ .../Penlight/docs/libraries/pl.permute.html | 354 ++++ .../Penlight/docs/libraries/pl.pretty.html | 402 ++++ Data/Libraries/Penlight/docs/libraries/pl.seq.html | 888 +++++++++ Data/Libraries/Penlight/docs/libraries/pl.sip.html | 399 ++++ .../Penlight/docs/libraries/pl.strict.html | 270 +++ .../Penlight/docs/libraries/pl.stringio.html | 215 +++ .../Penlight/docs/libraries/pl.stringx.html | 1239 ++++++++++++ .../Penlight/docs/libraries/pl.tablex.html | 1980 ++++++++++++++++++++ .../Penlight/docs/libraries/pl.template.html | 336 ++++ .../Libraries/Penlight/docs/libraries/pl.test.html | 445 +++++ .../Libraries/Penlight/docs/libraries/pl.text.html | 381 ++++ .../Penlight/docs/libraries/pl.types.html | 475 +++++ Data/Libraries/Penlight/docs/libraries/pl.url.html | 212 +++ .../Penlight/docs/libraries/pl.utils.html | 1384 ++++++++++++++ Data/Libraries/Penlight/docs/libraries/pl.xml.html | 835 +++++++++ 34 files changed, 19025 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.Set.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.app.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.array2d.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.class.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.compat.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.comprehension.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.config.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.data.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.dir.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.file.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.func.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.import_into.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.input.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.lapp.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.lexer.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.luabalanced.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.operator.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.path.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.permute.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.pretty.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.seq.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.sip.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.strict.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.stringio.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.stringx.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.tablex.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.template.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.test.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.text.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.types.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.url.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.utils.html create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.xml.html (limited to 'Data/Libraries/Penlight/docs/libraries') diff --git a/Data/Libraries/Penlight/docs/libraries/pl.Set.html b/Data/Libraries/Penlight/docs/libraries/pl.Set.html new file mode 100644 index 0000000..8eda41e --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.Set.html @@ -0,0 +1,650 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module 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)

+ + +

Functions

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

metamethods

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

+
    + + a list +
+ + + + +
+
+ + 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 +
+ + + + +
+
+ + union (self, set) +
+
+ union of two sets (also +). + + +

Parameters:

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

Returns:

+
    + + a new 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]
    +
+ +
+
+ + 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 +
+ + + + +
+
+ + issubset (self, set) +
+
+ is the first set a subset of the second (also <)?. + + +

Parameters:

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

Returns:

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

Parameters:

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

Returns:

+
    + + true or false +
+ + + + +
+
+ + 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 +
+ + + + +
+
+ + len (s) +
+
+ size of this set (also # for 5.2). + + +

Parameters:

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

Returns:

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

metamethods

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

Parameters:

+
    +
  • s1 + +
  • +
  • s2 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-11-23 21:07:42 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.app.html b/Data/Libraries/Penlight/docs/libraries/pl.app.html new file mode 100644 index 0000000..4417e8f --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.app.html @@ -0,0 +1,397 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.app

+

Application support functions.

+

See the Guide

+ +

Dependencies: pl.utils, pl.path

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
script_name ()return the name of the current script running.
require_here (base)prefixes the current script's path to the Lua module path.
appfile (file)return a suitable path for files private to this application.
platform ()return string indicating operating system.
lua ()return the full command-line used to invoke this script.
parse_args (args, flags_with_values, flags_valid)parse command-line arguments into flags and parameters.
+ +
+
+ + +

Functions

+ +
+
+ + script_name () +
+
+ return the name of the current script running. + The name will be the name as passed on the command line + + + +

Returns:

+
    + + string filename +
+ + + + +
+
+ + require_here (base) +
+
+ prefixes the current script's path to the Lua module path. + Applies to both the source and the binary module paths. It makes it easy for + the main file of a multi-file program to access its modules in the same directory. + base allows these modules to be put in a specified subdirectory, to allow for + cleaner deployment and resolve potential conflicts between a script name and its + library directory.

+ +

Note: the path is prefixed, so it is searched first when requiring modules. + + +

Parameters:

+
    +
  • base + string + optional base directory (absolute, or relative path). +
  • +
+ +

Returns:

+
    + + string + the current script's path with a trailing slash +
+ + + + +
+
+ + appfile (file) +
+
+ return a suitable path for files private to this application. + These will look like '~/.SNAME/file', with '~' as with expanduser and + SNAME is the name of the script without .lua extension. + If the directory does not exist, it will be created. + + +

Parameters:

+
    +
  • file + string + a filename (w/out path) +
  • +
+ +

Returns:

+
    +
  1. + a full pathname, or nil
  2. +
  3. + cannot create directory error
  4. +
+ + + +

Usage:

+
    +
    -- when run from a script called 'testapp' (on Windows):
    +local app = require 'pl.app'
    +print(app.appfile 'test.txt')
    +-- C:\Documents and Settings\steve\.testapp\test.txt
    +
+ +
+
+ + platform () +
+
+ return string indicating operating system. + + + +

Returns:

+
    + + 'Windows','OSX' or whatever uname returns (e.g. 'Linux') +
+ + + + +
+
+ + lua () +
+
+ return the full command-line used to invoke this script. + It will not include the scriptname itself, see app.script_name. + + + +

Returns:

+
    +
  1. + command-line
  2. +
  3. + name of Lua program used
  4. +
+ + + +

Usage:

+
    +
    -- execute:  lua -lluacov -e 'print(_VERSION)' myscript.lua
    +
    +-- myscript.lua
    +print(require("pl.app").lua())  --> "lua -lluacov -e 'print(_VERSION)'", "lua"
    +
+ +
+
+ + parse_args (args, flags_with_values, flags_valid) +
+
+ parse command-line arguments into flags and parameters. + Understands GNU-style command-line flags; short (-f) and long (--flag).

+ +

These may be given a value with either '=' or ':' (-k:2,--alpha=3.2,-n2), + a number value can be given without a space. If the flag is marked + as having a value, then a space-separated value is also accepted (-i hello), + see the flags_with_values argument).

+ +

Multiple short args can be combined like so: ( -abcd).

+ +

When specifying the flags_valid parameter, its contents can also contain + aliasses, to convert short/long flags to the same output name. See the + example below.

+ +

Note: if a flag is repeated, the last value wins. + + +

Parameters:

+
    +
  • args + {string} + an array of strings (default is the global arg) +
  • +
  • flags_with_values + tab + any flags that take values, either list or hash + table e.g. { out=true } or { "out" }. +
  • +
  • flags_valid + tab + (optional) flags that are valid, either list or hashtable. + If not given, everything + will be accepted(everything in flags_with_values will automatically be allowed) +
  • +
+ +

Returns:

+
    +
  1. + a table of flags (flag=value pairs)
  2. +
  3. + an array of parameters
  4. +
+ +

Raises:

+ if args is nil, then the global args must be available! + + +

Usage:

+
    +
    -- Simple form:
    +local flags, params = app.parse_args(nil,
    +     { "hello", "world" },  -- list of flags taking values
    +     { "l", "a", "b"})      -- list of allowed flags (value ones will be added)
    +
    +-- More complex example using aliasses:
    +local valid = {
    +    long = "l",           -- if 'l' is specified, it is reported as 'long'
    +    new = { "n", "old" }, -- here both 'n' and 'old' will go into 'new'
    +}
    +local values = {
    +    "value",   -- will automatically be added to the allowed set of flags
    +    "new",     -- will mark 'n' and 'old' as requiring a value as well
    +}
    +local flags, params = app.parse_args(nil, values, valid)
    +
    +-- command:  myapp.lua -l --old:hello --value world param1 param2
    +-- will yield:
    +flags = {
    +    long = true,     -- input from 'l'
    +    new = "hello",   -- input from 'old'
    +    value = "world", -- allowed because it was in 'values', note: space separated!
    +}
    +params = {
    +    [1] = "param1"
    +    [2] = "param2"
    +}
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.array2d.html b/Data/Libraries/Penlight/docs/libraries/pl.array2d.html new file mode 100644 index 0000000..8ee905b --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.array2d.html @@ -0,0 +1,1319 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.array2d

+

Operations on two-dimensional arrays.

+

See The Guide

+ +

The size of the arrays is determined by using the length operator # hence + the module is not nil safe, and the usual precautions apply.

+ +

Note: all functions taking i1,j1,i2,j2 as arguments will normalize the + arguments using default_range.

+ +

Dependencies: pl.utils, pl.tablex, pl.types

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
size (a)return the row and column size.
column (a, j)extract a column from the 2D array.
row (a, i)extract a row from the 2D array.
map (f, a, arg)map a function over a 2D array
reduce_rows (f, a)reduce the rows using a function.
reduce_cols (f, a)reduce the columns using a function.
reduce2 (opc, opr, a)reduce a 2D array into a scalar, using two operations.
map2 (f, ad, bd, a, b, arg)map a function over two arrays.
product (f, t1, t2)cartesian product of two 1d arrays.
flatten (t)flatten a 2D array.
reshape (t, nrows, co)reshape a 2D array.
transpose (t)transpose a 2D array.
swap_rows (t, i1, i2)swap two rows of an array.
swap_cols (t, j1, j2)swap two columns of an array.
extract_rows (t, ridx)extract the specified rows.
extract_cols (t, cidx)extract the specified columns.
remove_row (t, i)remove a row from an array.
remove_col (t, j)remove a column from an array.
parse_range (s)parse a spreadsheet range.
range (t, rstr)get a slice of a 2D array using spreadsheet range notation.
default_range (t, i1, j1, i2, j2)normalizes coordinates to valid positive entries and defaults.
slice (t, i1, j1, i2, j2)get a slice of a 2D array.
set (t, value, i1, j1, i2, j2)set a specified range of an array to a value.
write (t, f, fmt, i1, j1, i2, j2)write a 2D array to a file.
forall (t, row_op, end_row_op, i1, j1, i2, j2)perform an operation for all values in a 2D array.
move (dest, di, dj, src, i1, j1, i2, j2)move a block from the destination to the source.
iter (a, indices, i1, j1, i2, j2)iterate over all elements in a 2D array, with optional indices.
columns (a)iterate over all columns.
rows (a)iterate over all rows.
new (rows, cols, val)new array of specified dimensions
+ +
+
+ + +

Functions

+ +
+
+ + size (a) +
+
+ return the row and column size. + Size is calculated using the Lua length operator #, so usual precautions + regarding nil values apply. + + +

Parameters:

+
    +
  • a + array + a 2d array +
  • +
+ +

Returns:

+
    +
  1. + int + number of rows (#a)
  2. +
  3. + int + number of cols (#a[1])
  4. +
+ + + + +
+
+ + column (a, j) +
+
+ extract a column from the 2D array. + + +

Parameters:

+
    +
  • a + array + 2d array +
  • +
  • j + column index +
  • +
+ +

Returns:

+
    + + 1d array +
+ + + + +
+
+ + row (a, i) +
+
+ extract a row from the 2D array. + Added in line with column, for read-only purposes directly + accessing a[i] is more performant. + + +

Parameters:

+
    +
  • a + array + 2d array +
  • +
  • i + row index +
  • +
+ +

Returns:

+
    + + 1d array (copy of the row) +
+ + + + +
+
+ + map (f, a, arg) +
+
+ map a function over a 2D array + + +

Parameters:

+
    +
  • f + func + a function of at least one argument +
  • +
  • a + array + 2d array +
  • +
  • arg + an optional extra argument to be passed to the function. +
  • +
+ +

Returns:

+
    + + 2d array +
+ + + + +
+
+ + reduce_rows (f, a) +
+
+ reduce the rows using a function. + + +

Parameters:

+
    +
  • f + func + a binary function +
  • +
  • a + array + 2d array +
  • +
+ +

Returns:

+
    + + 1d array +
+ + +

See also:

+ + + +
+
+ + reduce_cols (f, a) +
+
+ reduce the columns using a function. + + +

Parameters:

+
    +
  • f + func + a binary function +
  • +
  • a + array + 2d array +
  • +
+ +

Returns:

+
    + + 1d array +
+ + +

See also:

+ + + +
+
+ + reduce2 (opc, opr, a) +
+
+ reduce a 2D array into a scalar, using two operations. + + +

Parameters:

+
    +
  • opc + func + operation to reduce the final result +
  • +
  • opr + func + operation to reduce the rows +
  • +
  • a + 2D array +
  • +
+ + + + + +
+
+ + map2 (f, ad, bd, a, b, arg) +
+
+ map a function over two arrays. + They can be both or either 2D arrays + + +

Parameters:

+
    +
  • f + func + function of at least two arguments +
  • +
  • ad + int + order of first array (1 if a is a list/array, 2 if it is a 2d array) +
  • +
  • bd + int + order of second array (1 if b is a list/array, 2 if it is a 2d array) +
  • +
  • a + tab + 1d or 2d array +
  • +
  • b + tab + 1d or 2d array +
  • +
  • arg + optional extra argument to pass to function +
  • +
+ +

Returns:

+
    + + 2D array, unless both arrays are 1D +
+ + + + +
+
+ + product (f, t1, t2) +
+
+ cartesian product of two 1d arrays. + + +

Parameters:

+
    +
  • f + func + a function of 2 arguments +
  • +
  • t1 + array + a 1d table +
  • +
  • t2 + array + a 1d table +
  • +
+ +

Returns:

+
    + + 2d table +
+ + + +

Usage:

+
    +
    product('..',{1,2},{'a','b'}) == {{'1a','2a'},{'1b','2b'}}
    +
+ +
+
+ + flatten (t) +
+
+ flatten a 2D array. + (this goes over columns first.) + + +

Parameters:

+
    +
  • t + array + 2d table +
  • +
+ +

Returns:

+
    + + a 1d table +
+ + + +

Usage:

+
    +
    flatten {{1,2},{3,4},{5,6}} == {1,2,3,4,5,6}
    +
+ +
+
+ + reshape (t, nrows, co) +
+
+ reshape a 2D array. Reshape the aray by specifying a new nr of rows. + + +

Parameters:

+
    +
  • t + array + 2d array +
  • +
  • nrows + int + new number of rows +
  • +
  • co + bool + use column-order (Fortran-style) (default false) +
  • +
+ +

Returns:

+
    + + a new 2d array +
+ + + + +
+
+ + transpose (t) +
+
+ transpose a 2D array. + + +

Parameters:

+
    +
  • t + array + 2d array +
  • +
+ +

Returns:

+
    + + a new 2d array +
+ + + + +
+
+ + swap_rows (t, i1, i2) +
+
+ swap two rows of an array. + + +

Parameters:

+
    +
  • t + array + a 2d array +
  • +
  • i1 + int + a row index +
  • +
  • i2 + int + a row index +
  • +
+ +

Returns:

+
    + + t (same, modified 2d array) +
+ + + + +
+
+ + swap_cols (t, j1, j2) +
+
+ swap two columns of an array. + + +

Parameters:

+
    +
  • t + array + a 2d array +
  • +
  • j1 + int + a column index +
  • +
  • j2 + int + a column index +
  • +
+ +

Returns:

+
    + + t (same, modified 2d array) +
+ + + + +
+
+ + extract_rows (t, ridx) +
+
+ extract the specified rows. + + +

Parameters:

+
    +
  • t + array + 2d array +
  • +
  • ridx + {int} + a table of row indices +
  • +
+ +

Returns:

+
    + + a new 2d array with the extracted rows +
+ + + + +
+
+ + extract_cols (t, cidx) +
+
+ extract the specified columns. + + +

Parameters:

+
    +
  • t + array + 2d array +
  • +
  • cidx + {int} + a table of column indices +
  • +
+ +

Returns:

+
    + + a new 2d array with the extracted colums +
+ + + + +
+
+ + remove_row (t, i) +
+
+ remove a row from an array. + + +

Parameters:

+
    +
  • t + array + a 2d array +
  • +
  • i + int + a row index +
  • +
+ + + + + +
+
+ + remove_col (t, j) +
+
+ remove a column from an array. + + +

Parameters:

+
    +
  • t + array + a 2d array +
  • +
  • j + int + a column index +
  • +
+ + + + + +
+
+ + parse_range (s) +
+
+ parse a spreadsheet range. + The range can be specified either as 'A1:B2' or 'R1C1:R2C2'; + a special case is a single element (e.g 'A1' or 'R1C1') + + +

Parameters:

+
    +
  • s + string + a range (case insensitive). +
  • +
+ +

Returns:

+
    +
  1. + int + start row
  2. +
  3. + int + start col
  4. +
  5. + int + end row
  6. +
  7. + int + end col
  8. +
+ + + + +
+
+ + range (t, rstr) +
+
+ get a slice of a 2D array using spreadsheet range notation. @see parse_range + + +

Parameters:

+
    +
  • t + array + a 2D array +
  • +
  • rstr + string + range expression +
  • +
+ +

Returns:

+
    + + a slice +
+ + +

See also:

+ + + +
+
+ + default_range (t, i1, j1, i2, j2) +
+
+ normalizes coordinates to valid positive entries and defaults. + Negative indices will be counted from the end, too low, or too high + will be limited by the array sizes. + + +

Parameters:

+
    +
  • t + array + a 2D array +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) + return i1, j1, i2, j2 +
  • +
+ + + + + +
+
+ + slice (t, i1, j1, i2, j2) +
+
+ get a slice of a 2D array. Note that if the specified range has + a 1D result, the rank of the result will be 1. + + +

Parameters:

+
    +
  • t + array + a 2D array +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ +

Returns:

+
    + + an array, 2D in general but 1D in special cases. +
+ + + + +
+
+ + set (t, value, i1, j1, i2, j2) +
+
+ set a specified range of an array to a value. + + +

Parameters:

+
    +
  • t + array + a 2D array +
  • +
  • value + the value (may be a function, called as val(i,j)) +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ + + +

See also:

+ + + +
+
+ + write (t, f, fmt, i1, j1, i2, j2) +
+
+ write a 2D array to a file. + + +

Parameters:

+
    +
  • t + array + a 2D array +
  • +
  • f + a file object (default stdout) +
  • +
  • fmt + string + a format string (default is just to use tostring) +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ + + + + +
+
+ + forall (t, row_op, end_row_op, i1, j1, i2, j2) +
+
+ perform an operation for all values in a 2D array. + + +

Parameters:

+
    +
  • t + array + 2D array +
  • +
  • row_op + func + function to call on each value; row_op(row,j) +
  • +
  • end_row_op + func + function to call at end of each row; end_row_op(i) +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ + + + + +
+
+ + move (dest, di, dj, src, i1, j1, i2, j2) +
+
+ move a block from the destination to the source. + + +

Parameters:

+
    +
  • dest + array + a 2D array +
  • +
  • di + int + start row in dest +
  • +
  • dj + int + start col in dest +
  • +
  • src + array + a 2D array +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ + + + + +
+
+ + iter (a, indices, i1, j1, i2, j2) +
+
+ iterate over all elements in a 2D array, with optional indices. + + +

Parameters:

+
    +
  • a + array + 2D array +
  • +
  • indices + bool + with indices (default false) +
  • +
  • i1 + int + start row (default 1) +
  • +
  • j1 + int + start col (default 1) +
  • +
  • i2 + int + end row (default N) +
  • +
  • j2 + int + end col (default M) +
  • +
+ +

Returns:

+
    + + either value or i,j,value depending on the value of indices +
+ + + + +
+
+ + columns (a) +
+
+ iterate over all columns. + + +

Parameters:

+
    +
  • a + array + a 2D array +
  • +
+ +

Returns:

+
    + + column, column-index +
+ + + + +
+
+ + rows (a) +
+
+ iterate over all rows. + Returns a copy of the row, for read-only purrposes directly iterating + is more performant; ipairs(a) + + +

Parameters:

+
    +
  • a + array + a 2D array +
  • +
+ +

Returns:

+
    + + row, row-index +
+ + + + +
+
+ + new (rows, cols, val) +
+
+ new array of specified dimensions + + +

Parameters:

+
    +
  • rows + int + number of rows +
  • +
  • cols + int + number of cols +
  • +
  • val + initial value; if it's a function then use val(i,j) +
  • +
+ +

Returns:

+
    + + new 2d array +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.class.html b/Data/Libraries/Penlight/docs/libraries/pl.class.html new file mode 100644 index 0000000..b623e94 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.class.html @@ -0,0 +1,332 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.class

+

Provides a reuseable and convenient framework for creating classes in Lua.

+

Two possible notations:

+ + +
+B = class(A)
+class.B(A)
+
+ +

The latter form creates a named class within the current environment. Note + that this implicitly brings in pl.utils as a dependency.

+ +

See the Guide for further discussion

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + +
_init (...)initializes an instance upon creation.
instance:is_a (some_class)checks whether an instance is derived from some class.
some_class:class_of (some_instance)checks whether an instance is derived from some class.
some_class:cast (some_instance)cast an object to another class.
class (base, c_arg, c)create a new class, derived from a given base class.
+ +
+
+ + +

Functions

+ +
+
+ + _init (...) +
+
+ initializes an instance upon creation. + + +

Parameters:

+
    +
  • ... + parameters passed to the constructor +
  • +
+ + + + +

Usage:

+
    +
    local Cat = class()
    +function Cat:_init(name)
    +  --self:super(name)   -- call the ancestor initializer if needed
    +  self.name = name
    +end
    +
    +local pussycat = Cat("pussycat")
    +print(pussycat.name)  --> pussycat
    +
+ +
+
+ + instance:is_a (some_class) +
+
+ checks whether an instance is derived from some class. + Works the other way around as class_of. It has two ways of using; + 1) call with a class to check against, 2) call without params. + + +

Parameters:

+
    +
  • some_class + class to check against, or nil to return the class +
  • +
+ +

Returns:

+
    + + true if instance is derived from some_class, or if some_class == nil then + it returns the class table of the instance +
+ + + +

Usage:

+
    +
    local pussycat = Lion()  -- assuming Lion derives from Cat
    +if pussycat:is_a(Cat) then
    +  -- it's true, it is a Lion, but also a Cat
    +end
    +
    +if pussycat:is_a() == Lion then
    +  -- It's true
    +end
    +
+ +
+
+ + some_class:class_of (some_instance) +
+
+ checks whether an instance is derived from some class. + Works the other way around as is_a. + + +

Parameters:

+
    +
  • some_instance + instance to check against +
  • +
+ +

Returns:

+
    + + true if some_instance is derived from some_class +
+ + + +

Usage:

+
    +
    local pussycat = Lion()  -- assuming Lion derives from Cat
    +if Cat:class_of(pussycat) then
    +  -- it's true
    +end
    +
+ +
+
+ + some_class:cast (some_instance) +
+
+ cast an object to another class. + It is not clever (or safe!) so use carefully. + + +

Parameters:

+
    +
  • some_instance + the object to be changed +
  • +
+ + + + + +
+
+ + class (base, c_arg, c) +
+
+ create a new class, derived from a given base class. + Supporting two class creation syntaxes: + either Name = class(base) or class.Name(base). + The first form returns the class directly and does not set its _name. + The second form creates a variable Name in the current environment set + to the class, and also sets _name. + + +

Parameters:

+
    +
  • base + optional base class +
  • +
  • c_arg + optional parameter to class constructor +
  • +
  • c + optional table to be used as class +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.compat.html b/Data/Libraries/Penlight/docs/libraries/pl.compat.html new file mode 100644 index 0000000..6680030 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.compat.html @@ -0,0 +1,580 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.compat

+

Lua 5.1/5.2/5.3 compatibility.

+

Injects table.pack, table.unpack, and package.searchpath in the global + environment, to make sure they are available for Lua 5.1 and LuaJIT.

+ +

All other functions are exported as usual in the returned module table.

+ +

NOTE: everything in this module is also available in pl.utils.

+ + +

Functions

+ + + + + + + + + + + + + + + + + +
execute (cmd)execute a shell command, in a compatible and platform independent way.
load (ld[, source[, mode[, env]]])Load Lua code as a text or binary chunk (in a Lua 5.2 compatible way).
getfenv (f)Get environment of a function (in a Lua 5.1 compatible way).
setfenv (f, env)Set environment of a function (in a Lua 5.1 compatible way).
+

Fields

+ + + + + + + + + + + + + + + + + + + + + +
lua51boolean flag this is Lua 5.1 (or LuaJIT).
jitboolean flag this is LuaJIT.
jit52boolean flag this is LuaJIT with 5.2 compatibility compiled in.
dir_separatorthe directory separator character for the current platform.
is_windowsboolean flag this is a Windows platform.
+

Global exported functions (for Lua 5.1 & LuaJIT)

+ + + + + + + + + + + + + +
table.pack (...)pack an argument list into a table.
table.unpack (t[, i[, t]])unpack a table and return the elements.
package.searchpath (name, path[, sep[, rep]])return the full path where a file name would be matched.
+

Global exported functions (for Lua < 5.4)

+ + + + + +
warn (...)raise a warning message.
+ +
+
+ + +

Functions

+ +
+
+ + execute (cmd) +
+
+ execute a shell command, in a compatible and platform independent way. + This is a compatibility function that returns the same for Lua 5.1 and + Lua 5.2+.

+ +

NOTE: Windows systems can use signed 32bit integer exitcodes. Posix systems + only use exitcodes 0-255, anything else is undefined.

+ +

NOTE2: In Lua 5.2 and 5.3 a Windows exitcode of -1 would not properly be + returned, this function will return it properly for all versions. + + +

Parameters:

+
    +
  • cmd + a shell command +
  • +
+ +

Returns:

+
    +
  1. + true if successful
  2. +
  3. + actual return code
  4. +
+ + + + +
+
+ + load (ld[, source[, mode[, env]]]) +
+
+ Load Lua code as a text or binary chunk (in a Lua 5.2 compatible way). + + +

Parameters:

+
    +
  • ld + code string or loader +
  • +
  • source + name of chunk for errors + (optional) +
  • +
  • mode + 'b', 't' or 'bt' + (optional) +
  • +
  • env + environment to load the chunk in + (optional) +
  • +
+ + + + + +
+
+ + getfenv (f) +
+
+ Get environment of a function (in a Lua 5.1 compatible way). + Not 100% compatible, so with Lua 5.2 it may return nil for a function with no + global references! + Based on code by Sergey Rozhenko + + +

Parameters:

+
    +
  • f + a function or a call stack reference +
  • +
+ + + + + +
+
+ + setfenv (f, env) +
+
+ Set environment of a function (in a Lua 5.1 compatible way). + + +

Parameters:

+
    +
  • f + a function or a call stack reference +
  • +
  • env + a table that becomes the new environment of f +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + lua51 +
+
+ boolean flag this is Lua 5.1 (or LuaJIT). + + +
    +
  • lua51 + + + +
  • +
+ + + + + +
+
+ + jit +
+
+ boolean flag this is LuaJIT. + + +
    +
  • jit + + + +
  • +
+ + + + + +
+
+ + jit52 +
+
+ boolean flag this is LuaJIT with 5.2 compatibility compiled in. + + +
    +
  • jit52 + + + +
  • +
+ + + + + +
+
+ + dir_separator +
+
+ the directory separator character for the current platform. + + +
    +
  • dir_separator + + + +
  • +
+ + + + + +
+
+ + is_windows +
+
+ boolean flag this is a Windows platform. + + +
    +
  • is_windows + + + +
  • +
+ + + + + +
+
+

Global exported functions (for Lua 5.1 & LuaJIT)

+ +
+
+ + table.pack (...) +
+
+ pack an argument list into a table. + + +

Parameters:

+
    +
  • ... + any arguments +
  • +
+ +

Returns:

+
    + + a table with field n set to the length +
+ + + + +
+
+ + table.unpack (t[, i[, t]]) +
+
+ unpack a table and return the elements.

+ +

NOTE: this version does NOT honor the n field, and hence it is not nil-safe. + See utils.unpack for a version that is nil-safe. + + +

Parameters:

+
    +
  • t + index of the last element to unpack, defaults to #t + (optional) +
  • +
  • i + index from which to start unpacking, defaults to 1 + (optional) +
  • +
  • t + index of the last element to unpack, defaults to #t + (optional) +
  • +
+ +

Returns:

+
    + + multiple return values from the table +
+ + +

See also:

+ + + +
+
+ + package.searchpath (name, path[, sep[, rep]]) +
+
+ return the full path where a file name would be matched. + This function was introduced in Lua 5.2, so this compatibility version + will be injected in Lua 5.1 engines. + + +

Parameters:

+
    +
  • name + string + file name, possibly dotted +
  • +
  • path + string + a path-template in the same form as package.path or package.cpath +
  • +
  • sep + string + template separate character to be replaced by path separator. Default: "." + (optional) +
  • +
  • rep + string + the path separator to use, defaults to system separator. Default; "/" on Unixes, "\" on Windows. + (optional) +
  • +
+ +

Returns:

+
    +
  1. + on success: path of the file
  2. +
  3. + on failure: nil, error string listing paths tried
  4. +
+ + +

See also:

+ + + +
+
+

Global exported functions (for Lua < 5.4)

+ +
+
+ + warn (...) +
+
+ raise a warning message. + This functions mimics the warn function added in Lua 5.4. + + +

Parameters:

+
    +
  • ... + any arguments +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html b/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html new file mode 100644 index 0000000..4c31b64 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html @@ -0,0 +1,165 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.comprehension

+

List comprehensions implemented in Lua.

+

See the wiki page

+ + +
+local C= require 'pl.comprehension' . new()
+
+C ('x for x=1,10') ()
+==> {1,2,3,4,5,6,7,8,9,10}
+C 'x^2 for x=1,4' ()
+==> {1,4,9,16}
+C '{x,x^2} for x=1,4' ()
+==> {{1,1},{2,4},{3,9},{4,16}}
+C '2*x for x' {1,2,3}
+==> {2,4,6}
+dbl = C '2*x for x'
+dbl {10,20,30}
+==> {20,40,60}
+C 'x for x if x % 2 == 0' {1,2,3,4,5}
+==> {2,4}
+C '{x,y} for x = 1,2 for y = 1,2' ()
+==> {{1,1},{1,2},{2,1},{2,2}}
+C '{x,y} for x for y' ({1,2},{10,20})
+==> {{1,10},{1,20},{2,10},{2,20}}
+assert(C 'sum(x^2 for x)' {2,3,4} == 2^2+3^2+4^2)
+
+ +

(c) 2008 David Manura. Licensed under the same terms as Lua (MIT license).

+ +

Dependencies: pl.utils, pl.luabalanced

+ +

See the Guide

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.config.html b/Data/Libraries/Penlight/docs/libraries/pl.config.html new file mode 100644 index 0000000..1ad8833 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.config.html @@ -0,0 +1,259 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.config

+

Reads configuration files into a Lua table.

+

+ +

Understands INI files, classic Unix config files, and simple + delimited columns of values. See the Guide

+ + +
+# test.config
+# Read timeout in seconds
+read.timeout=10
+# Write timeout in seconds
+write.timeout=5
+#acceptable ports
+ports = 1002,1003,1004
+
+-- readconfig.lua
+local config = require 'config'
+local t = config.read 'test.config'
+print(pretty.write(t))
+
+### output #####
+{
+  ports = {
+    1002,
+    1003,
+    1004
+  },
+  write_timeout = 5,
+  read_timeout = 10
+}
+
+ +

+ + +

Functions

+ + + + + + + + + +
lines (file)like io.lines(), but allows for lines to be continued with ''.
read (file[, cnfg])read a configuration file into a table
+ +
+
+ + +

Functions

+ +
+
+ + lines (file) +
+
+ like io.lines(), but allows for lines to be continued with ''. + + +

Parameters:

+
    +
  • file + a file-like object (anything where read() returns the next line) or a filename. + Defaults to stardard input. +
  • +
+ +

Returns:

+
    +
  1. + an iterator over the lines, or nil
  2. +
  3. + error 'not a file-like object' or 'file is nil'
  4. +
+ + + + +
+
+ + read (file[, cnfg]) +
+
+ read a configuration file into a table + + +

Parameters:

+
    +
  • file + either a file-like object or a string, which must be a filename +
  • +
  • cnfg + tab + +

    a configuration table that may contain these fields:

    + +
      +
    • smart try to deduce what kind of config file we have (default false)
    • +
    • variabilize make names into valid Lua identifiers (default true)
    • +
    • convert_numbers try to convert values into numbers (default true)
    • +
    • trim_space ensure that there is no starting or trailing whitespace with values (default true)
    • +
    • trim_quotes remove quotes from strings (default false)
    • +
    • list_delim delimiter to use when separating columns (default ',')
    • +
    • keysep separator between key and value pairs (default '=')
    • +
    + + + (optional) +
  • +
+ +

Returns:

+
    +
  1. + a table containing items, or nil
  2. +
  3. + error message (same as config.lines
  4. +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.data.html b/Data/Libraries/Penlight/docs/libraries/pl.data.html new file mode 100644 index 0000000..736e82e --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.data.html @@ -0,0 +1,571 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.data

+

Reading and querying simple tabular data.

+

+ + + +

+data.read 'test.txt'
+==> {{10,20},{2,5},{40,50},fieldnames={'x','y'},delim=','}
+
+ +

Provides a way of creating basic SQL-like queries.

+ + +
+require 'pl'
+local d = data.read('xyz.txt')
+local q = d:select('x,y,z where x > 3 and z < 2 sort by y')
+for x,y,z in q do
+    print(x,y,z)
+end
+
+ +

See the Guide

+ +

Dependencies: pl.utils, pl.array2d (fallback methods)

+

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Data.column_by_name (name)return a particular column as a list of values (method).
Data.select (condn)return a query iterator on this data (method).
Data.select_row (condn)return a row iterator on this data (method).
Data.copy_select (condn)return a new data object based on this query (method).
Data.column_names ()return the field names of this data object (method).
Data.write_row (f)write out a row (method).
Data.write (f)write data out to file (method).
read (file, cnfg)read a delimited file in a Lua table.
write (data, file[, fieldnames[, delim='\t']])write 2D data to a file.
new (d[, fieldnames])create a new dataset from a table of rows.
query (data, condn, context, return_row)create a query iterator from a select string.
filter (Q, infile, outfile, dont_fail)Filter input using a query.
+ +
+
+ + +

Functions

+ +
+
+ + Data.column_by_name (name) +
+
+ return a particular column as a list of values (method). + + +

Parameters:

+
    +
  • name + either name of column, or numerical index. +
  • +
+ + + + + +
+
+ + Data.select (condn) +
+
+ return a query iterator on this data (method). + + +

Parameters:

+
    +
  • condn + string + the query expression +
  • +
+ + + +

See also:

+ + + +
+
+ + Data.select_row (condn) +
+
+ return a row iterator on this data (method). + + +

Parameters:

+
    +
  • condn + string + the query expression +
  • +
+ + + + + +
+
+ + Data.copy_select (condn) +
+
+ return a new data object based on this query (method). + + +

Parameters:

+
    +
  • condn + string + the query expression +
  • +
+ + + + + +
+
+ + Data.column_names () +
+
+ return the field names of this data object (method). + + + + + + + +
+
+ + Data.write_row (f) +
+
+ write out a row (method). + + +

Parameters:

+
    +
  • f + file-like object +
  • +
+ + + + + +
+
+ + Data.write (f) +
+
+ write data out to file (method). + + +

Parameters:

+
    +
  • f + file-like object +
  • +
+ + + + + +
+
+ + read (file, cnfg) +
+
+ read a delimited file in a Lua table. + By default, attempts to treat first line as separated list of fieldnames. + + +

Parameters:

+
    +
  • file + a filename or a file-like object +
  • +
  • cnfg parsing options +
      +
    • delim + string + a string pattern to split fields +
    • +
    • fieldnames + array + (i.e. don't read from first line) +
    • +
    • no_convert + bool + (default is to try conversion on first data line) +
    • +
    • convert + tab + table of custom conversion functions with column keys +
    • +
    • numfields + int + indices of columns known to be numbers +
    • +
    • last_field_collect + bool + only split as many fields as fieldnames. +
    • +
    • thousands_dot + int + thousands separator in Excel CSV is '.' +
    • +
    • csv + bool + fields may be double-quoted and contain commas; + Also, empty fields are considered to be equivalent to zero. +
    • +
    +
+ +

Returns:

+
    +
  1. + data object, or nil
  2. +
  3. + error message. May be a file error, 'not a file-like object' + or a conversion error
  4. +
+ + + + +
+
+ + write (data, file[, fieldnames[, delim='\t']]) +
+
+ write 2D data to a file. + Does not assume that the data has actually been + generated with new or read. + + +

Parameters:

+
    +
  • data + 2D array +
  • +
  • file + filename or file-like object +
  • +
  • fieldnames + {string} + list of fields (optional) + (optional) +
  • +
  • delim + string + delimiter (default tab) + (default '\t') +
  • +
+ +

Returns:

+
    + + true or nil, error +
+ + + + +
+
+ + new (d[, fieldnames]) +
+
+ create a new dataset from a table of rows. + Can specify the fieldnames, else the table must have a field called + 'fieldnames', which is either a string of delimiter-separated names, + or a table of names.
+ If the table does not have a field called 'delim', then an attempt will be + made to guess it from the fieldnames string, defaults otherwise to tab. + + +

Parameters:

+
    +
  • d + the table. +
  • +
  • fieldnames + {string} + optional fieldnames + (optional) +
  • +
+ +

Returns:

+
    + + the table. +
+ + + + +
+
+ + query (data, condn, context, return_row) +
+
+ create a query iterator from a select string. + Select string has this format:
+ FIELDLIST [ where LUA-CONDN [ sort by FIELD] ]
+ FIELDLIST is a comma-separated list of valid fields, or '*'.

+ The condition can also be a table, with fields 'fields' (comma-sep string or + table), 'sort_by' (string) and 'where' (Lua expression string or function) + + +

Parameters:

+
    +
  • data + table produced by read +
  • +
  • condn + select string or table +
  • +
  • context + a list of tables to be searched when resolving functions +
  • +
  • return_row + if true, wrap the results in a row table +
  • +
+ +

Returns:

+
    +
  1. + an iterator over the specified fields, or nil
  2. +
  3. + an error message
  4. +
+ + + + +
+
+ + filter (Q, infile, outfile, dont_fail) +
+
+ Filter input using a query. + + +

Parameters:

+
    +
  • Q + string + a query string +
  • +
  • infile + filename or file-like object +
  • +
  • outfile + filename or file-like object +
  • +
  • dont_fail + bool + true if you want to return an error, not just fail +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.dir.html b/Data/Libraries/Penlight/docs/libraries/pl.dir.html new file mode 100644 index 0000000..5dfa0f6 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.dir.html @@ -0,0 +1,615 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.dir

+

Listing files in directories and creating/removing directory paths.

+

Dependencies: pl.utils, pl.path

+ +

Soft Dependencies: alien, ffi (either are used on Windows for copying/moving files)

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fnmatch (filename, pattern)Test whether a file name matches a shell pattern.
filter (filenames, pattern)Return a list of all file names within an array which match a pattern.
getfiles (dirname, mask)return a list of all files in a directory which match a shell pattern.
getdirectories (dirname)return a list of all subdirectories of the directory.
copyfile (src, dest, flag)copy a file.
movefile (src, dest)move a file.
walk (root, bottom_up, follow_links)return an iterator which walks through a directory tree starting at root.
rmtree (fullpath)remove a whole directory tree.
makepath (p)create a directory path.
clonetree (path1, path2, file_fun, verbose)clone a directory tree.
dirtree (d)return an iterator over all entries in a directory tree
getallfiles (start_path, shell_pattern)Recursively returns all the file starting at path.
+ +
+
+ + +

Functions

+ +
+
+ + fnmatch (filename, pattern) +
+
+ Test whether a file name matches a shell pattern. + Both parameters are case-normalized if operating system is + case-insensitive. + + +

Parameters:

+
    +
  • filename + string + A file name. +
  • +
  • pattern + string + A shell pattern. The only special characters are + '*' and '?': '*' matches any sequence of characters and + '?' matches any single character. +
  • +
+ +

Returns:

+
    + + bool + + + +
+ +

Raises:

+ dir and mask must be strings + + + +
+
+ + filter (filenames, pattern) +
+
+ Return a list of all file names within an array which match a pattern. + + +

Parameters:

+
    +
  • filenames + tab + An array containing file names. +
  • +
  • pattern + string + A shell pattern. +
  • +
+ +

Returns:

+
    + + List(string) + List of matching file names. +
+ +

Raises:

+ dir and mask must be strings + + + +
+
+ + getfiles (dirname, mask) +
+
+ return a list of all files in a directory which match a shell pattern. + + +

Parameters:

+
    +
  • dirname + string + A directory. If not given, all files in current directory are returned. +
  • +
  • mask + string + A shell pattern. If not given, all files are returned. +
  • +
+ +

Returns:

+
    + + {string} + list of files +
+ +

Raises:

+ dirname and mask must be strings + + + +
+
+ + getdirectories (dirname) +
+
+ return a list of all subdirectories of the directory. + + +

Parameters:

+
    +
  • dirname + string + A directory +
  • +
+ +

Returns:

+
    + + {string} + a list of directories +
+ +

Raises:

+ dir must be a a valid directory + + + +
+
+ + copyfile (src, dest, flag) +
+
+ copy a file. + + +

Parameters:

+
    +
  • src + string + source file +
  • +
  • dest + string + destination file or directory +
  • +
  • flag + bool + true if you want to force the copy (default) +
  • +
+ +

Returns:

+
    + + bool + operation succeeded +
+ +

Raises:

+ src and dest must be strings + + + +
+
+ + movefile (src, dest) +
+
+ move a file. + + +

Parameters:

+
    +
  • src + string + source file +
  • +
  • dest + string + destination file or directory +
  • +
+ +

Returns:

+
    + + bool + operation succeeded +
+ +

Raises:

+ src and dest must be strings + + + +
+
+ + walk (root, bottom_up, follow_links) +
+
+ return an iterator which walks through a directory tree starting at root. + The iterator returns (root,dirs,files) + Note that dirs and files are lists of names (i.e. you must say path.join(root,d) + to get the actual full path) + If bottom_up is false (or not present), then the entries at the current level are returned + before we go deeper. This means that you can modify the returned list of directories before + continuing. + This is a clone of os.walk from the Python libraries. + + +

Parameters:

+
    +
  • root + string + A starting directory +
  • +
  • bottom_up + bool + False if we start listing entries immediately. +
  • +
  • follow_links + bool + follow symbolic links +
  • +
+ +

Returns:

+
    + + an iterator returning root,dirs,files +
+ +

Raises:

+ root must be a directory + + + +
+
+ + rmtree (fullpath) +
+
+ remove a whole directory tree. + Symlinks in the tree will be deleted without following them. + + +

Parameters:

+
    +
  • fullpath + string + A directory path (must be an actual directory, not a symlink) +
  • +
+ +

Returns:

+
    +
  1. + true or nil
  2. +
  3. + error if failed
  4. +
+ +

Raises:

+ fullpath must be a string + + + +
+
+ + makepath (p) +
+
+ create a directory path. + This will create subdirectories as necessary! + + +

Parameters:

+
    +
  • p + string + A directory path +
  • +
+ +

Returns:

+
    + + true on success, nil + errormsg on failure +
+ +

Raises:

+ failure to create + + + +
+
+ + clonetree (path1, path2, file_fun, verbose) +
+
+ clone a directory tree. Will always try to create a new directory structure + if necessary. + + +

Parameters:

+
    +
  • path1 + string + the base path of the source tree +
  • +
  • path2 + string + the new base path for the destination +
  • +
  • file_fun + func + an optional function to apply on all files +
  • +
  • verbose + bool + an optional boolean to control the verbosity of the output. + It can also be a logging function that behaves like print() +
  • +
+ +

Returns:

+
    +
  1. + true, or nil
  2. +
  3. + error message, or list of failed directory creations
  4. +
  5. + list of failed file operations
  6. +
+ +

Raises:

+ path1 and path2 must be strings + + +

Usage:

+
    +
    clonetree('.','../backup',copyfile)
    +
+ +
+
+ + dirtree (d) +
+
+ return an iterator over all entries in a directory tree + + +

Parameters:

+
    +
  • d + string + a directory +
  • +
+ +

Returns:

+
    + + an iterator giving pathname and mode (true for dir, false otherwise) +
+ +

Raises:

+ d must be a non-empty string + + + +
+
+ + getallfiles (start_path, shell_pattern) +
+
+ Recursively returns all the file starting at path. It can optionally take a shell pattern and + only returns files that match shellpattern_. If a pattern is given it will do a case insensitive search. + + +

Parameters:

+
    +
  • start_path + string + A directory. If not given, all files in current directory are returned. +
  • +
  • shell_pattern + string + A shell pattern. If not given, all files are returned. +
  • +
+ +

Returns:

+
    + + List(string) + containing all the files found recursively starting at path and filtered by shellpattern_. +
+ +

Raises:

+ start_path must be a directory + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.file.html b/Data/Libraries/Penlight/docs/libraries/pl.file.html new file mode 100644 index 0000000..bd36aca --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.file.html @@ -0,0 +1,301 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.file

+

File manipulation functions: reading, writing, moving and copying.

+

This module wraps a number of functions from other modules into a + file related module for convenience.

+ +

Dependencies: pl.utils, pl.dir, pl.path

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
read ()return the contents of a file as a string.
write ()write a string to a file.
copy ()copy a file.
move ()move a file.
access_time ()Return the time of last access as the number of seconds since the epoch.
creation_time ()Return when the file was created.
modified_time ()Return the time of last modification.
delete ()Delete a file.
+ +
+
+ + +

Functions

+ +
+
+ + read () +
+
+ return the contents of a file as a string. + This function is a copy of utils.readfile. + + + + + + + +
+
+ + write () +
+
+ write a string to a file. + This function is a copy of utils.writefile. + + + + + + + +
+
+ + copy () +
+
+ copy a file. + This function is a copy of dir.copyfile. + + + + + + + +
+
+ + move () +
+
+ move a file. + This function is a copy of dir.movefile. + + + + + + + +
+
+ + access_time () +
+
+ Return the time of last access as the number of seconds since the epoch. + This function is a copy of path.getatime. + + + + + + + +
+
+ + creation_time () +
+
+ Return when the file was created. + This function is a copy of path.getctime. + + + + + + + +
+
+ + modified_time () +
+
+ Return the time of last modification. + This function is a copy of path.getmtime. + + + + + + + +
+
+ + delete () +
+
+ Delete a file. + This function is a copy of os.remove. + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.func.html b/Data/Libraries/Penlight/docs/libraries/pl.func.html new file mode 100644 index 0000000..22e84a1 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.func.html @@ -0,0 +1,460 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.func

+

Functional helpers like composition, binding and placeholder expressions.

+

Placeholder expressions are useful for short anonymous functions, and were + inspired by the Boost Lambda library.

+ + +
+> utils.import 'pl.func'
+> ls = List{10,20,30}
+> = ls:map(_1+1)
+{11,21,31}
+
+ +

They can also be used to bind particular arguments of a function.

+ + +
+> p = bind(print,'start>',_0)
+> p(10,20,30)
+> start>   10   20  30
+
+ +

See the Guide

+ +

Dependencies: pl.utils, pl.tablex

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
import (tname, context)wrap a table of functions.
register (fun[, name])register a function for use in placeholder expressions.
tail (ls)all elements of a table except the first.
repr (e, lastpred)create a string representation of a placeholder expression.
instantiate (e)instantiate a PE into an actual function.
I (e)instantiate a PE unless it has already been done.
bind1 (fn, p)bind the first parameter of the function to a value.
compose (f, g)create a function which chains two functions.
bind (fn, ...)bind the arguments of a function to given values.
+ +
+
+ + +

Functions

+ +
+
+ + import (tname, context) +
+
+ wrap a table of functions. This makes them available for use in + placeholder expressions. + + +

Parameters:

+
    +
  • tname + string + a table name +
  • +
  • context + tab + context to put results, defaults to environment of caller +
  • +
+ + + + + +
+
+ + register (fun[, name]) +
+
+ register a function for use in placeholder expressions. + + +

Parameters:

+
    +
  • fun + func + a function +
  • +
  • name + string + an optional name + (optional) +
  • +
+ +

Returns:

+
    + + a placeholder functiond +
+ + + + +
+
+ + tail (ls) +
+
+ all elements of a table except the first. + + +

Parameters:

+
    +
  • ls + tab + a list-like table. +
  • +
+ + + + + +
+
+ + repr (e, lastpred) +
+
+ create a string representation of a placeholder expression. + + +

Parameters:

+
    +
  • e + a placeholder expression +
  • +
  • lastpred + not used +
  • +
+ + + + + +
+
+ + instantiate (e) +
+
+ instantiate a PE into an actual function. First we find the largest placeholder used, + e.g. 2; from this a list of the formal parameters can be build. Then we collect and replace + any non-PE values from the PE, and build up a constant binding list. + Finally, the expression can be compiled, and e.PEfunction is set. + + +

Parameters:

+
    +
  • e + a placeholder expression +
  • +
+ +

Returns:

+
    + + a function +
+ + + + +
+
+ + I (e) +
+
+ instantiate a PE unless it has already been done. + + +

Parameters:

+
    +
  • e + a placeholder expression +
  • +
+ +

Returns:

+
    + + the function +
+ + + + +
+
+ + bind1 (fn, p) +
+
+ bind the first parameter of the function to a value. + + +

Parameters:

+
    +
  • fn + func + a function of one or more arguments +
  • +
  • p + a value +
  • +
+ +

Returns:

+
    + + a function of one less argument +
+ + + +

Usage:

+
    +
    (bind1(math.max,10))(20) == math.max(10,20)
    +
+ +
+
+ + compose (f, g) +
+
+ create a function which chains two functions. + + +

Parameters:

+
    +
  • f + func + a function of at least one argument +
  • +
  • g + func + a function of at least one argument +
  • +
+ +

Returns:

+
    + + a function +
+ + + +

Usage:

+
    +
    printf = compose(io.write,string.format)
    +
+ +
+
+ + bind (fn, ...) +
+
+ bind the arguments of a function to given values. + bind(fn,v,_2) is equivalent to bind1(fn,v). + + +

Parameters:

+
    +
  • fn + func + a function of at least one argument +
  • +
  • ... + values or placeholder variables +
  • +
+ +

Returns:

+
    + + a function +
+ + + +

Usage:

+
    +
  • (bind(f,_1,a))(b) == f(a,b)
  • +
  • (bind(f,_2,_1))(a,b) == f(b,a)
  • +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.html b/Data/Libraries/Penlight/docs/libraries/pl.html new file mode 100644 index 0000000..f3d134f --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.html @@ -0,0 +1,139 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl

+

Entry point for loading all PL libraries only on demand, into the global space.

+

Requiring 'pl' means that whenever a module is implicitly accesssed + (e.g. utils.split) + then that module is dynamically loaded. The submodules are all brought into + the global space. +Updated to use pl.import_into

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.import_into.html b/Data/Libraries/Penlight/docs/libraries/pl.import_into.html new file mode 100644 index 0000000..5f92459 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.import_into.html @@ -0,0 +1,142 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.import_into

+

PL loader, for loading all PL libraries, only on demand.

+

Whenever a module is implicitly accesssed, the table will have the module automatically injected. + (e.g. _ENV.tablex) + then that module is dynamically loaded. The submodules are all brought into + the table that is provided as the argument, or returned in a new table. + If a table is provided, that table's metatable is clobbered, but the values are not. + This module returns a single function, which is passed the environment. + If this is true, then return a 'shadow table' as the module + See the Guide

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.input.html b/Data/Libraries/Penlight/docs/libraries/pl.input.html new file mode 100644 index 0000000..d0086fd --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.input.html @@ -0,0 +1,336 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.input

+

Iterators for extracting words or numbers from an input source.

+

+ + + +

+require 'pl'
+local total,n = seq.sum(input.numbers())
+print('average',total/n)
+
+ +

source is defined as a string or a file-like object (i.e. has a read() method which returns the next line)

+ +

See here

+ +

Dependencies: pl.utils

+

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + +
alltokens (getter, pattern[, fn])create an iterator over all tokens.
create_getter (f)create a function which grabs the next value from a source.
numbers (f)generate a sequence of numbers from a source.
words (f)generate a sequence of words from a source.
fields (ids, delim, f, opts)parse an input source into fields.
+ +
+
+ + +

Functions

+ +
+
+ + alltokens (getter, pattern[, fn]) +
+
+ create an iterator over all tokens. + based on allwords from PiL, 7.1 + + +

Parameters:

+
    +
  • getter + func + any function that returns a line of text +
  • +
  • pattern + string + + + +
  • +
  • fn + string + Optionally can pass a function to process each token as it's found. + (optional) +
  • +
+ +

Returns:

+
    + + an iterator +
+ + + + +
+
+ + create_getter (f) +
+
+ create a function which grabs the next value from a source. If the source is a string, then the getter + will return the string and thereafter return nil. If not specified then the source is assumed to be stdin. + + +

Parameters:

+
    +
  • f + a string or a file-like object (i.e. has a read() method which returns the next line) +
  • +
+ +

Returns:

+
    + + a getter function +
+ + + + +
+
+ + numbers (f) +
+
+ generate a sequence of numbers from a source. + + +

Parameters:

+
    +
  • f + A source +
  • +
+ +

Returns:

+
    + + An iterator +
+ + + + +
+
+ + words (f) +
+
+ generate a sequence of words from a source. + + +

Parameters:

+
    +
  • f + A source +
  • +
+ +

Returns:

+
    + + An iterator +
+ + + + +
+
+ + fields (ids, delim, f, opts) +
+
+ parse an input source into fields. + By default, will fail if it cannot convert a field to a number. + + +

Parameters:

+
    +
  • ids + a list of field indices, or a maximum field index +
  • +
  • delim + string + delimiter to parse fields (default space) +
  • +
  • f + a source @see create_getter +
  • +
  • opts + tab + option table, {no_fail=true} +
  • +
+ +

Returns:

+
    + + an iterator with the field values +
+ + + +

Usage:

+
    +
    for x,y in fields {2,3} do print(x,y) end -- 2nd and 3rd fields from stdin
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.lapp.html b/Data/Libraries/Penlight/docs/libraries/pl.lapp.html new file mode 100644 index 0000000..24a1079 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.lapp.html @@ -0,0 +1,382 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.lapp

+

Simple command-line parsing using human-readable specification.

+

Supports GNU-style parameters.

+ + +
+lapp = require 'pl.lapp'
+local args = lapp [[
+Does some calculations
+  -o,--offset (default 0.0)  Offset to add to scaled number
+  -s,--scale  (number)  Scaling factor
+  <number> (number) Number to be scaled
+]]
+
+print(args.offset + args.scale * args.number)
+
+ +

Lines beginning with '-' are flags; there may be a short and a long name; + lines beginning with '<var>' are arguments. Anything in parens after + the flag/argument is either a default, a type name or a range constraint.

+ +

See the Guide

+ +

Dependencies: pl.sip

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
quit (msg, no_usage)quit this script immediately.
error (msg, no_usage)print an error to stderr and quit.
open (file[, opt])open a file.
assert (condn, msg)quit if the condition is false.
add_type (name, converter[, constraint])add a new type to Lapp.
process_options_string (str, args)process a Lapp options string.
+

Fields

+ + + + + +
show_usage_errorcontrols whether to dump usage on error.
+ +
+
+ + +

Functions

+ +
+
+ + quit (msg, no_usage) +
+
+ quit this script immediately. + + +

Parameters:

+
    +
  • msg + string + optional message +
  • +
  • no_usage + bool + suppress 'usage' display +
  • +
+ + + + + +
+
+ + error (msg, no_usage) +
+
+ print an error to stderr and quit. + + +

Parameters:

+
    +
  • msg + string + a message +
  • +
  • no_usage + bool + suppress 'usage' display +
  • +
+ + + + + +
+
+ + open (file[, opt]) +
+
+ open a file. + This will quit on error, and keep a list of file objects for later cleanup. + + +

Parameters:

+
    +
  • file + string + filename +
  • +
  • opt + string + same as second parameter of io.open + (optional) +
  • +
+ + + + + +
+
+ + assert (condn, msg) +
+
+ quit if the condition is false. + + +

Parameters:

+
    +
  • condn + bool + a condition +
  • +
  • msg + string + message text +
  • +
+ + + + + +
+
+ + add_type (name, converter[, constraint]) +
+
+ add a new type to Lapp. These appear in parens after the value like + a range constraint, e.g. ' (integer) Process PID' + + +

Parameters:

+
    +
  • name + string + name of type +
  • +
  • converter + either a function to convert values, or a Lua type name. +
  • +
  • constraint + func + optional function to verify values, should use lapp.error + if failed. + (optional) +
  • +
+ + + + + +
+
+ + process_options_string (str, args) +
+
+ process a Lapp options string. + Usually called as lapp(). + + +

Parameters:

+
    +
  • str + string + the options text +
  • +
  • args + {string} + a table of arguments (default is _G.arg) +
  • +
+ +

Returns:

+
    + + a table with parameter-value pairs +
+ + + + +
+
+

Fields

+ +
+
+ + show_usage_error +
+
+ controls whether to dump usage on error. + Defaults to true + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.lexer.html b/Data/Libraries/Penlight/docs/libraries/pl.lexer.html new file mode 100644 index 0000000..7b3d6fd --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.lexer.html @@ -0,0 +1,524 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.lexer

+

Lexical scanner for creating a sequence of tokens from text.

+

lexer.scan(s) returns an iterator over all tokens found in the + string s. This iterator returns two values, a token type string + (such as 'string' for quoted string, 'iden' for identifier) and the value of the + token.

+ +

Versions specialized for Lua and C are available; these also handle block comments + and classify keywords as 'keyword' tokens. For example:

+ + +
+> s = 'for i=1,n do'
+> for t,v in lexer.lua(s)  do print(t,v) end
+keyword for
+iden    i
+=       =
+number  1
+,       ,
+iden    n
+keyword do
+
+ +

See the Guide for further discussion

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
scan (s, matches[, filter[, options]])create a plain token iterator from a string or file-like object.
insert (tok, a1, a2)insert tokens into a stream.
getline (tok)get everything in a stream upto a newline.
lineno (tok)get current line number.
getrest (tok)get the rest of the stream.
get_keywords ()get the Lua keywords as a set-like table.
lua (s[, filter[, options]])create a Lua token iterator from a string or file-like object.
cpp (s[, filter[, options]])create a C/C++ token iterator from a string or file-like object.
get_separated_list (tok[, endtoken=')'[, delim=']])get a list of parameters separated by a delimiter from a stream.
skipws (tok)get the next non-space token from the stream.
expecting (tok, expected_type, no_skip_ws)get the next token, which must be of the expected type.
+ +
+
+ + +

Functions

+ +
+
+ + scan (s, matches[, filter[, options]]) +
+
+ create a plain token iterator from a string or file-like object. + + +

Parameters:

+
    +
  • s + string or file + a string or a file-like object with :read() method returning lines. +
  • +
  • matches + tab + an optional match table - array of token descriptions. + A token is described by a {pattern, action} pair, where pattern should match + token body and action is a function called when a token of described type is found. +
  • +
  • filter + tab + a table of token types to exclude, by default {space=true} + (optional) +
  • +
  • options + tab + a table of options; by default, {number=true,string=true}, + which means convert numbers and strip string quotes. + (optional) +
  • +
+ + + + + +
+
+ + insert (tok, a1, a2) +
+
+ insert tokens into a stream. + + +

Parameters:

+
    +
  • tok + a token stream +
  • +
  • a1 + a string is the type, a table is a token list and + a function is assumed to be a token-like iterator (returns type & value) +
  • +
  • a2 + string + a string is the value +
  • +
+ + + + + +
+
+ + getline (tok) +
+
+ get everything in a stream upto a newline. + + +

Parameters:

+
    +
  • tok + a token stream +
  • +
+ +

Returns:

+
    + + a string +
+ + + + +
+
+ + lineno (tok) +
+
+ get current line number. + + +

Parameters:

+
    +
  • tok + a token stream +
  • +
+ +

Returns:

+
    + + the line number. + if the input source is a file-like object, + also return the column. +
+ + + + +
+
+ + getrest (tok) +
+
+ get the rest of the stream. + + +

Parameters:

+
    +
  • tok + a token stream +
  • +
+ +

Returns:

+
    + + a string +
+ + + + +
+
+ + get_keywords () +
+
+ get the Lua keywords as a set-like table. + So res["and"] etc would be true. + + + +

Returns:

+
    + + a table +
+ + + + +
+
+ + lua (s[, filter[, options]]) +
+
+ create a Lua token iterator from a string or file-like object. + Will return the token type and value. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • filter + tab + a table of token types to exclude, by default {space=true,comments=true} + (optional) +
  • +
  • options + tab + a table of options; by default, {number=true,string=true}, + which means convert numbers and strip string quotes. + (optional) +
  • +
+ + + + + +
+
+ + cpp (s[, filter[, options]]) +
+
+ create a C/C++ token iterator from a string or file-like object. + Will return the token type type and value. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • filter + tab + a table of token types to exclude, by default {space=true,comments=true} + (optional) +
  • +
  • options + tab + a table of options; by default, {number=true,string=true}, + which means convert numbers and strip string quotes. + (optional) +
  • +
+ + + + + +
+
+ + get_separated_list (tok[, endtoken=')'[, delim=']]) +
+
+ get a list of parameters separated by a delimiter from a stream. + + +

Parameters:

+
    +
  • tok + the token stream +
  • +
  • endtoken + string + end of list. Can be '\n' + (default ')') +
  • +
  • delim + string + separator + (default ') +
  • +
+ +

Returns:

+
    + + a list of token lists. +
+ + + + +
+
+ + skipws (tok) +
+
+ get the next non-space token from the stream. + + +

Parameters:

+
    +
  • tok + the token stream. +
  • +
+ + + + + +
+
+ + expecting (tok, expected_type, no_skip_ws) +
+
+ get the next token, which must be of the expected type. + Throws an error if this type does not match! + + +

Parameters:

+
    +
  • tok + the token stream +
  • +
  • expected_type + string + the token type +
  • +
  • no_skip_ws + bool + whether we should skip whitespace +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.luabalanced.html b/Data/Libraries/Penlight/docs/libraries/pl.luabalanced.html new file mode 100644 index 0000000..48f6c63 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.luabalanced.html @@ -0,0 +1,149 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.luabalanced

+

Extract delimited Lua sequences from strings.

+

Inspired by Damian Conway's Text::Balanced in Perl.
+

    +
  • [1] Lua Wiki Page
  • +
  • [2] http://search.cpan.org/dist/Text-Balanced/lib/Text/Balanced.pm
  • +

+
+ local lb = require "pl.luabalanced"
+ --Extract Lua expression starting at position 4.
+  print(lb.match_expression("if x^2 + x > 5 then print(x) end", 4))
+  --> x^2 + x > 5     16
+ --Extract Lua string starting at (default) position 1.
+ print(lb.match_string([["test\"123" .. "more"]]))
+ --> "test\"123"     12
+ 
+ (c) 2008, David Manura, Licensed under the same terms as Lua (MIT license).

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.operator.html b/Data/Libraries/Penlight/docs/libraries/pl.operator.html new file mode 100644 index 0000000..fdd4cfb --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.operator.html @@ -0,0 +1,819 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.operator

+

Lua operators available as functions.

+

(similar to the Python module of the same name)

+ +

There is a module field optable which maps the operator strings + onto these functions, e.g. operator.optable['()']==operator.call

+ +

Operator strings like '>' and '{}' can be passed to most Penlight functions + expecting a function argument.

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
call (fn, ...)apply function to some arguments ()
index (t, k)get the indexed value from a table []
eq (a, b)returns true if arguments are equal ==
neq (a, b)returns true if arguments are not equal ~=
lt (a, b)returns true if a is less than b <
le (a, b)returns true if a is less or equal to b <=
gt (a, b)returns true if a is greater than b >
ge (a, b)returns true if a is greater or equal to b >=
len (a)returns length of string or table #
add (a, b)add two values +
sub (a, b)subtract b from a -
mul (a, b)multiply two values *
div (a, b)divide first value by second /
pow (a, b)raise first to the power of second ^
mod (a, b)modulo; remainder of a divided by b %
concat (a, b)concatenate two values (either strings or __concat defined) ..
unm (a)return the negative of a value -
lnot (a)false if value evaluates as true not
land (a, b)true if both values evaluate as true and
lor (a, b)true if either value evaluate as true or
table (...)make a table from the arguments {}
match (a, b)match two strings ~.
nop (...)the null operation.
+

Tables

+ + + + + +
optableMap from operator symbol to function.
+ +
+
+ + +

Functions

+ +
+
+ + call (fn, ...) +
+
+ apply function to some arguments () + + +

Parameters:

+
    +
  • fn + a function or callable object +
  • +
  • ... + arguments +
  • +
+ + + + + +
+
+ + index (t, k) +
+
+ get the indexed value from a table [] + + +

Parameters:

+
    +
  • t + a table or any indexable object +
  • +
  • k + the key +
  • +
+ + + + + +
+
+ + eq (a, b) +
+
+ returns true if arguments are equal == + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + neq (a, b) +
+
+ returns true if arguments are not equal ~= + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + lt (a, b) +
+
+ returns true if a is less than b < + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + le (a, b) +
+
+ returns true if a is less or equal to b <= + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + gt (a, b) +
+
+ returns true if a is greater than b > + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + ge (a, b) +
+
+ returns true if a is greater or equal to b >= + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + len (a) +
+
+ returns length of string or table # + + +

Parameters:

+
    +
  • a + a string or a table +
  • +
+ + + + + +
+
+ + add (a, b) +
+
+ add two values + + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + sub (a, b) +
+
+ subtract b from a - + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + mul (a, b) +
+
+ multiply two values * + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + div (a, b) +
+
+ divide first value by second / + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + pow (a, b) +
+
+ raise first to the power of second ^ + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + mod (a, b) +
+
+ modulo; remainder of a divided by b % + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + concat (a, b) +
+
+ concatenate two values (either strings or __concat defined) .. + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + unm (a) +
+
+ return the negative of a value - + + +

Parameters:

+
    +
  • a + value +
  • +
+ + + + + +
+
+ + lnot (a) +
+
+ false if value evaluates as true not + + +

Parameters:

+
    +
  • a + value +
  • +
+ + + + + +
+
+ + land (a, b) +
+
+ true if both values evaluate as true and + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + lor (a, b) +
+
+ true if either value evaluate as true or + + +

Parameters:

+
    +
  • a + value +
  • +
  • b + value +
  • +
+ + + + + +
+
+ + table (...) +
+
+ make a table from the arguments {} + + +

Parameters:

+
    +
  • ... + non-nil arguments +
  • +
+ +

Returns:

+
    + + a table +
+ + + + +
+
+ + match (a, b) +
+
+ match two strings ~. + uses string.find + + +

Parameters:

+
    +
  • a + + + +
  • +
  • b + + + +
  • +
+ + + + + +
+
+ + nop (...) +
+
+ the null operation. + + +

Parameters:

+
    +
  • ... + arguments +
  • +
+ +

Returns:

+
    + + the arguments +
+ + + + +
+
+

Tables

+ +
+
+ + optable +
+
+ +

Map from operator symbol to function. + Most of these map directly from operators; + But note these extras

+ + + + + + +

Fields:

+
    +
  • operator + + + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.path.html b/Data/Libraries/Penlight/docs/libraries/pl.path.html new file mode 100644 index 0000000..6345f6b --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.path.html @@ -0,0 +1,1070 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.path

+

Path manipulation and file queries.

+

This is modelled after Python's os.path library (10.1); see the Guide.

+ +

NOTE: the functions assume the paths being dealt with to originate + from the OS the application is running on. Windows drive letters are not + to be used when running on a Unix system for example. The one exception + is Windows paths to allow both forward and backward slashes (since Lua + also accepts those)

+ +

Dependencies: pl.utils, lfs

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dir ()Lua iterator over the entries of a given directory.
mkdir ()Creates a directory.
rmdir ()Removes a directory.
attrib ()Gets attributes.
currentdir ()Get the working directory.
link_attrib ()Gets symlink attributes.
chdir ()Changes the working directory.
isdir (P)is this a directory?
isfile (P)is this a file?
getsize (P)return size of a file.
exists (P)does a path exist?
getatime (P)Return the time of last access as the number of seconds since the epoch.
getmtime (P)Return the time of last modification as the number of seconds since the epoch.
getctime (P)Return the system's ctime as the number of seconds since the epoch.
splitpath (P)given a path, return the directory part and a file part.
abspath (P[, pwd])return an absolute path.
splitext (P)given a path, return the root part and the extension part.
dirname (P)return the directory part of a path
basename (P)return the file part of a path
extension (P)get the extension part of a path.
isabs (P)is this an absolute path?
join (p1, p2, ...)return the path resulting from combining the individual paths.
normcase (P)normalize the case of a pathname.
normpath (P)normalize a path name.
relpath (P[, start])relative path from current directory or optional start point
expanduser (P)Replace a starting '~' with the user's home directory.
tmpname ()Return a suitable full path to a new temporary file name.
common_prefix (path1, path2)return the largest common prefix path of two paths.
package_path (mod)return the full path where a particular Lua module would be found.
+

Fields

+ + + + + + + + + + + + + +
is_windowsare we running Windows?
seppath separator for this platform.
dirsepseparator for PATH for this platform
+ +
+
+ + +

Functions

+ +
+
+ + dir () +
+
+ Lua iterator over the entries of a given directory. + Implicit link to luafilesystem.dir + + + + + + + +
+
+ + mkdir () +
+
+ Creates a directory. + Implicit link to luafilesystem.mkdir + + + + + + + +
+
+ + rmdir () +
+
+ Removes a directory. + Implicit link to luafilesystem.rmdir + + + + + + + +
+
+ + attrib () +
+
+ Gets attributes. + Implicit link to luafilesystem.attributes + + + + + + + +
+
+ + currentdir () +
+
+ Get the working directory. + Implicit link to luafilesystem.currentdir + + + + + + + +
+
+ + link_attrib () +
+
+ Gets symlink attributes. + Implicit link to luafilesystem.symlinkattributes + + + + + + + +
+
+ + chdir () +
+
+ Changes the working directory. + On Windows, if a drive is specified, it also changes the current drive. If + only specifying the drive, it will only switch drive, but not modify the path. + Implicit link to luafilesystem.chdir + + + + + + + +
+
+ + isdir (P) +
+
+ is this a directory? + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + isfile (P) +
+
+ is this a file? + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + getsize (P) +
+
+ return size of a file. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + exists (P) +
+
+ does a path exist? + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    + + the file path if it exists (either as file, directory, socket, etc), nil otherwise +
+ + + + +
+
+ + getatime (P) +
+
+ Return the time of last access as the number of seconds since the epoch. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + getmtime (P) +
+
+ Return the time of last modification as the number of seconds since the epoch. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + getctime (P) +
+
+ Return the system's ctime as the number of seconds since the epoch. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + splitpath (P) +
+
+ given a path, return the directory part and a file part. + if there's no directory part, the first value will be empty + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    +
  1. + directory part
  2. +
  3. + file part
  4. +
+ + + +

Usage:

+
    +
    local dir, file = path.splitpath("some/dir/myfile.txt")
    +assert(dir == "some/dir")
    +assert(file == "myfile.txt")
    +
    +local dir, file = path.splitpath("some/dir/")
    +assert(dir == "some/dir")
    +assert(file == "")
    +
    +local dir, file = path.splitpath("some_dir")
    +assert(dir == "")
    +assert(file == "some_dir")
    +
+ +
+
+ + abspath (P[, pwd]) +
+
+ return an absolute path. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
  • pwd + string + optional start path to use (default is current dir) + (optional) +
  • +
+ + + + + +
+
+ + splitext (P) +
+
+ given a path, return the root part and the extension part. + if there's no extension part, the second value will be empty + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    +
  1. + string + root part (everything upto the "."", maybe empty)
  2. +
  3. + string + extension part (including the ".", maybe empty)
  4. +
+ + + +

Usage:

+
    +
    local file_path, ext = path.splitext("/bonzo/dog_stuff/cat.txt")
    +assert(file_path == "/bonzo/dog_stuff/cat")
    +assert(ext == ".txt")
    +
    +local file_path, ext = path.splitext("")
    +assert(file_path == "")
    +assert(ext == "")
    +
+ +
+
+ + dirname (P) +
+
+ return the directory part of a path + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    + + string + everything before the last dir-separator +
+ + +

See also:

+ + +

Usage:

+
    +
    path.dirname("/some/path/file.txt")   -- "/some/path"
    +path.dirname("file.txt")              -- "" (empty string)
    +
+ +
+
+ + basename (P) +
+
+ return the file part of a path + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    + + string + + + +
+ + +

See also:

+ + +

Usage:

+
    +
    path.basename("/some/path/file.txt")  -- "file.txt"
    +path.basename("/some/path/file/")     -- "" (empty string)
    +
+ +
+
+ + extension (P) +
+
+ get the extension part of a path. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ +

Returns:

+
    + + string + + + +
+ + +

See also:

+ + +

Usage:

+
    +
    path.extension("/some/path/file.txt") -- ".txt"
    +path.extension("/some/path/file_txt") -- "" (empty string)
    +
+ +
+
+ + isabs (P) +
+
+ is this an absolute path? + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + +

Usage:

+
    +
    path.isabs("hello/path")    -- false
    +path.isabs("/hello/path")   -- true
    +-- Windows;
    +path.isabs("hello\path")    -- false
    +path.isabs("\hello\path")   -- true
    +path.isabs("C:\hello\path") -- true
    +path.isabs("C:hello\path")  -- false
    +
+ +
+
+ + join (p1, p2, ...) +
+
+ return the path resulting from combining the individual paths. + if the second (or later) path is absolute, we return the last absolute path (joined with any non-absolute paths following). + empty elements (except the last) will be ignored. + + +

Parameters:

+
    +
  • p1 + string + A file path +
  • +
  • p2 + string + A file path +
  • +
  • ... + string + more file paths +
  • +
+ +

Returns:

+
    + + string + the combined path +
+ + + +

Usage:

+
    +
    path.join("/first","second","third")   -- "/first/second/third"
    +path.join("first","second/third")      -- "first/second/third"
    +path.join("/first","/second","third")  -- "/second/third"
    +
+ +
+
+ + normcase (P) +
+
+ +

normalize the case of a pathname. On Unix, this returns the path unchanged, + for Windows it converts;

+ +
    +
  • the path to lowercase
  • +
  • forward slashes to backward slashes
  • +
+ + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + +

Usage:

+
    +
    path.normcase("/Some/Path/File.txt")
    +-- Windows: "\some\path\file.txt"
    +-- Others : "/Some/Path/File.txt"
    +
+ +
+
+ + normpath (P) +
+
+ normalize a path name. + A//B, A/./B, and A/foo/../B all become A/B.

+ +

An empty path results in '.'. + + +

Parameters:

+
    +
  • P + string + a file path +
  • +
+ + + + + +
+
+ + relpath (P[, start]) +
+
+ relative path from current directory or optional start point + + +

Parameters:

+
    +
  • P + string + a path +
  • +
  • start + string + optional start point (default current directory) + (optional) +
  • +
+ + + + + +
+
+ + expanduser (P) +
+
+ Replace a starting '~' with the user's home directory. + In windows, if HOME isn't set, then USERPROFILE is used in preference to + HOMEDRIVE HOMEPATH. This is guaranteed to be writeable on all versions of Windows. + + +

Parameters:

+
    +
  • P + string + A file path +
  • +
+ + + + + +
+
+ + tmpname () +
+
+ Return a suitable full path to a new temporary file name. + unlike os.tmpname(), it always gives you a writeable path (uses TEMP environment variable on Windows) + + + + + + + +
+
+ + common_prefix (path1, path2) +
+
+ return the largest common prefix path of two paths. + + +

Parameters:

+
    +
  • path1 + string + a file path +
  • +
  • path2 + string + a file path +
  • +
+ +

Returns:

+
    + + the common prefix (Windows: separators will be normalized, casing will be original) +
+ + + + +
+
+ + package_path (mod) +
+
+ return the full path where a particular Lua module would be found. + Both package.path and package.cpath is searched, so the result may + either be a Lua file or a shared library. + + +

Parameters:

+
    +
  • mod + string + name of the module +
  • +
+ +

Returns:

+
    +
  1. + on success: path of module, lua or binary
  2. +
  3. + on error: nil, error string listing paths tried
  4. +
+ + + + +
+
+

Fields

+ +
+
+ + is_windows +
+
+ are we running Windows? + + + + + + + +
+
+ + sep +
+
+ path separator for this platform. + + + + + + + +
+
+ + dirsep +
+
+ separator for PATH for this platform + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.permute.html b/Data/Libraries/Penlight/docs/libraries/pl.permute.html new file mode 100644 index 0000000..afb887e --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.permute.html @@ -0,0 +1,354 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.permute

+

Permutation operations.

+

Dependencies: pl.utils, pl.tablex

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
order_iter (a)an iterator over all order-permutations of the elements of a list.
order_table (a)construct a table containing all the order-permutations of a list.
list_iter (...)an iterator over all permutations of the elements of the given lists.
list_table (...)construct a table containing all the permutations of a set of lists.
iter (...)deprecated.
table (...)deprecated.
+ +
+
+ + +

Functions

+ +
+
+ + order_iter (a) +
+
+ an iterator over all order-permutations of the elements of a list. + Please note that the same list is returned each time, so do not keep references! + + +

Parameters:

+
    +
  • a + list-like table +
  • +
+ +

Returns:

+
    + + an iterator which provides the next permutation as a list +
+ + + + +
+
+ + order_table (a) +
+
+ construct a table containing all the order-permutations of a list. + + +

Parameters:

+
    +
  • a + list-like table +
  • +
+ +

Returns:

+
    + + a table of tables +
+ + + +

Usage:

+
    +
    permute.order_table {1,2,3} --> {{2,3,1},{3,2,1},{3,1,2},{1,3,2},{2,1,3},{1,2,3}}
    +
+ +
+
+ + list_iter (...) +
+
+ an iterator over all permutations of the elements of the given lists. + + +

Parameters:

+
    +
  • ... + list-like tables, they are nil-safe if a length-field n is provided (see utils.pack) +
  • +
+ +

Returns:

+
    + + an iterator which provides the next permutation as return values in the same order as the provided lists, preceeded by an index +
+ + + +

Usage:

+
    +
    local strs = utils.pack("one", nil, "three")  -- adds an 'n' field for nil-safety
    +local bools = utils.pack(true, false)
    +local iter = permute.list_iter(strs, bools)
    +
    +print(iter())    --> 1, one, true
    +print(iter())    --> 2, nil, true
    +print(iter())    --> 3, three, true
    +print(iter())    --> 4, one, false
    +print(iter())    --> 5, nil, false
    +print(iter())    --> 6, three, false
    +
+ +
+
+ + list_table (...) +
+
+ construct a table containing all the permutations of a set of lists. + + +

Parameters:

+
    +
  • ... + list-like tables, they are nil-safe if a length-field n is provided +
  • +
+ +

Returns:

+
    + + a list of lists, the sub-lists have an 'n' field for nil-safety +
+ + + +

Usage:

+
    +
    local strs = utils.pack("one", nil, "three")  -- adds an 'n' field for nil-safety
    +local bools = utils.pack(true, false)
    +local results = permute.list_table(strs, bools)
    +-- results = {
    +--   { "one, true, n = 2 }
    +--   { nil, true, n = 2 },
    +--   { "three, true, n = 2 },
    +--   { "one, false, n = 2 },
    +--   { nil, false, n = 2 },
    +--   { "three", false, n = 2 },
    +-- }
    +
+ +
+
+ + iter (...) +
+
+ deprecated. + + +

Parameters:

+
    +
  • ... + + + +
  • +
+ + + +

See also:

+ + + +
+
+ + table (...) +
+
+ deprecated. + + +

Parameters:

+
    +
  • ... + + + +
  • +
+ + + +

See also:

+ + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.pretty.html b/Data/Libraries/Penlight/docs/libraries/pl.pretty.html new file mode 100644 index 0000000..4561699 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.pretty.html @@ -0,0 +1,402 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.pretty

+

Pretty-printing Lua tables.

+

Also provides a sandboxed Lua table reader and + a function to present large numbers in human-friendly format.

+ +

Dependencies: pl.utils, pl.lexer, pl.stringx, debug

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
read (s)Read a string representation of a Lua table.
load (s[, env[, paranoid]])Read a Lua chunk.
write (tbl[, space[, not_clever]])Create a string representation of a Lua table.
dump (t[, filename])Dump a Lua table out to a file or stdout.
debug (...)Dump a series of arguments to stdout for debug purposes.
number (num[, kind[, prec]])Format large numbers nicely for human consumption.
+ +
+
+ + +

Functions

+ +
+
+ + read (s) +
+
+ Read a string representation of a Lua table. + This function loads and runs the string as Lua code, but bails out + if it contains a function definition. + Loaded string is executed in an empty environment. + + +

Parameters:

+
    +
  • s + string + string to read in {...} format, possibly with some whitespace + before or after the curly braces. A single line comment may be present + at the beginning. +
  • +
+ +

Returns:

+
    + + a table in case of success. + If loading the string failed, return nil and error message. + If executing loaded string failed, return nil and the error it raised. +
+ + + + +
+
+ + load (s[, env[, paranoid]]) +
+
+ Read a Lua chunk. + + +

Parameters:

+
    +
  • s + string + Lua code. +
  • +
  • env + tab + environment used to run the code, empty by default. + (optional) +
  • +
  • paranoid + bool + abort loading if any looping constructs a found in the code + and disable string methods. + (optional) +
  • +
+ +

Returns:

+
    + + the environment in case of success or nil and syntax or runtime error + if something went wrong. +
+ + + + +
+
+ + write (tbl[, space[, not_clever]]) +
+
+ Create a string representation of a Lua table. + This function never fails, but may complain by returning an + extra value. Normally puts out one item per line, using + the provided indent; set the second parameter to an empty string + if you want output on one line.

+ +

NOTE: this is NOT a serialization function, not a full blown + debug function. Checkout out respectively the + serpent + or inspect + Lua modules for that if you need them. + + +

Parameters:

+
    +
  • tbl + tab + Table to serialize to a string. +
  • +
  • space + string + The indent to use. + Defaults to two spaces; pass an empty string for no indentation. + (optional) +
  • +
  • not_clever + bool + Pass true for plain output, e.g {['key']=1}. + Defaults to false. + (optional) +
  • +
+ +

Returns:

+
    +
  1. + a string
  2. +
  3. + an optional error message
  4. +
+ + + + +
+
+ + dump (t[, filename]) +
+
+ Dump a Lua table out to a file or stdout. + + +

Parameters:

+
    +
  • t + tab + The table to write to a file or stdout. +
  • +
  • filename + string + File name to write too. Defaults to writing + to stdout. + (optional) +
  • +
+ + + + + +
+
+ + debug (...) +
+
+ Dump a series of arguments to stdout for debug purposes. + This function is attached to the module table __call method, to make it + extra easy to access. So the full:

+ +
 print(require("pl.pretty").write({...}))
+
+ +

Can be shortened to:

+ +
 require"pl.pretty" (...)
+
+ +

Any nil entries will be printed as "<nil>" to make them explicit. + + +

Parameters:

+
    +
  • ... + the parameters to dump to stdout. +
  • +
+ + + + +

Usage:

+
    +
    -- example debug output
    +require"pl.pretty" ("hello", nil, "world", { bye = "world", true} )
    +
    +-- output:
    +{
    +  ["arg 1"] = "hello",
    +  ["arg 2"] = "<nil>",
    +  ["arg 3"] = "world",
    +  ["arg 4"] = {
    +    true,
    +    bye = "world"
    +  }
    +}
    +
+ +
+
+ + number (num[, kind[, prec]]) +
+
+ Format large numbers nicely for human consumption. + + +

Parameters:

+
    +
  • num + number + a number. +
  • +
  • kind + string + one of 'M' (memory in KiB, MiB, etc.), + 'N' (postfixes are 'K', 'M' and 'B'), + or 'T' (use commas as thousands separator), 'N' by default. + (optional) +
  • +
  • prec + int + number of digits to use for 'M' and 'N', 1 by default. + (optional) +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.seq.html b/Data/Libraries/Penlight/docs/libraries/pl.seq.html new file mode 100644 index 0000000..e694581 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.seq.html @@ -0,0 +1,888 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.seq

+

Manipulating iterators as sequences.

+

See The Guide

+ +

Dependencies: pl.utils, pl.types, debug

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
matching (s)given a string, return a function(y) which matches y against the string.
list (t)sequence adaptor for a table.
keys (t)return the keys of the table.
range (start, finish)create an iterator over a numerical range.
minmax (iter)return the minimum and the maximum value of the sequence.
sum (iter, fn)return the sum and element count of the sequence.
copy (iter)create a table from the sequence.
copy2 (iter, i1, i2)create a table of pairs from the double-valued sequence.
copy_tuples (iter)create a table of 'tuples' from a multi-valued sequence.
random (n, l, u)return an iterator of random numbers.
sort (iter, comp)return an iterator to the sorted elements of a sequence.
zip (iter1, iter2)return an iterator which returns elements of two sequences.
count_map (iter)Makes a table where the key/values are the values and value counts of the sequence.
printall (iter, sep, nfields, fmt)print out a sequence iter with a separator.
map (fn, iter, arg)return a sequence where every element of a sequence has been transformed + by a function.
filter (iter, pred, arg)filter a sequence using a predicate function.
reduce (fn, iter, initval)'reduce' a sequence using a binary function.
take (iter, n)take the first n values from the sequence.
skip (iter, n)skip the first n values of a sequence
enum (iter)a sequence with a sequence count and the original value.
mapmethod (iter, name, arg1, arg2)map using a named method over a sequence.
last (iter)a sequence of (last,current) values from another sequence.
foreach (iter, fn)call the function on each element of the sequence.
lines (f, ...)create a wrapped iterator over all lines in the file.
+ +
+
+ + +

Functions

+ +
+
+ + matching (s) +
+
+ given a string, return a function(y) which matches y against the string. + + +

Parameters:

+
    +
  • s + a string +
  • +
+ + + + + +
+
+ + list (t) +
+
+ sequence adaptor for a table. Note that if any generic function is + passed a table, it will automatically use seq.list() + + +

Parameters:

+
    +
  • t + a list-like table +
  • +
+ + + + +

Usage:

+
    +
  • sum(list(t)) is the sum of all elements of t
  • +
  • for x in list(t) do...end
  • +
+ +
+
+ + keys (t) +
+
+ return the keys of the table. + + +

Parameters:

+
    +
  • t + an arbitrary table +
  • +
+ +

Returns:

+
    + + iterator over keys +
+ + + + +
+
+ + range (start, finish) +
+
+ create an iterator over a numerical range. Like the standard Python function xrange. + + +

Parameters:

+
    +
  • start + a number +
  • +
  • finish + a number greater than start +
  • +
+ + + + + +
+
+ + minmax (iter) +
+
+ return the minimum and the maximum value of the sequence. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
+ +

Returns:

+
    +
  1. + minimum value
  2. +
  3. + maximum value
  4. +
+ + + + +
+
+ + sum (iter, fn) +
+
+ return the sum and element count of the sequence. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
  • fn + an optional function to apply to the values +
  • +
+ + + + + +
+
+ + copy (iter) +
+
+ create a table from the sequence. (This will make the result a List.) + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
+ +

Returns:

+
    + + a List +
+ + + +

Usage:

+
    +
  • copy(list(ls)) is equal to ls
  • +
  • copy(list {1,2,3}) == List{1,2,3}
  • +
+ +
+
+ + copy2 (iter, i1, i2) +
+
+ create a table of pairs from the double-valued sequence. + + +

Parameters:

+
    +
  • iter + a double-valued sequence +
  • +
  • i1 + used to capture extra iterator values +
  • +
  • i2 + as with pairs & ipairs +
  • +
+ +

Returns:

+
    + + a list-like table +
+ + + +

Usage:

+
    +
    copy2(ipairs{10,20,30}) == {{1,10},{2,20},{3,30}}
    +
+ +
+
+ + copy_tuples (iter) +
+
+ create a table of 'tuples' from a multi-valued sequence. + A generalization of copy2 above + + +

Parameters:

+
    +
  • iter + a multiple-valued sequence +
  • +
+ +

Returns:

+
    + + a list-like table +
+ + + + +
+
+ + random (n, l, u) +
+
+ return an iterator of random numbers. + + +

Parameters:

+
    +
  • n + the length of the sequence +
  • +
  • l + same as the first optional argument to math.random +
  • +
  • u + same as the second optional argument to math.random +
  • +
+ +

Returns:

+
    + + a sequence +
+ + + + +
+
+ + sort (iter, comp) +
+
+ return an iterator to the sorted elements of a sequence. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
  • comp + an optional comparison function (comp(x,y) is true if x < y) +
  • +
+ + + + + +
+
+ + zip (iter1, iter2) +
+
+ return an iterator which returns elements of two sequences. + + +

Parameters:

+
    +
  • iter1 + a sequence +
  • +
  • iter2 + a sequence +
  • +
+ + + + +

Usage:

+
    +
    for x,y in seq.zip(ls1,ls2) do....end
    +
+ +
+
+ + count_map (iter) +
+
+ Makes a table where the key/values are the values and value counts of the sequence. + This version works with 'hashable' values like strings and numbers. + pl.tablex.count_map is more general. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
+ +

Returns:

+
    +
  1. + a map-like table
  2. +
  3. + a table
  4. +
+ + +

See also:

+ + + +
+
+ + printall (iter, sep, nfields, fmt) +
+
+ print out a sequence iter with a separator. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
  • sep + the separator (default space) +
  • +
  • nfields + maximum number of values per line (default 7) +
  • +
  • fmt + optional format function for each value +
  • +
+ + + + + +
+
+ + map (fn, iter, arg) +
+
+ return a sequence where every element of a sequence has been transformed + by a function. If you don't supply an argument, then the function will + receive both values of a double-valued sequence, otherwise behaves rather like + tablex.map. + + +

Parameters:

+
    +
  • fn + a function to apply to elements; may take two arguments +
  • +
  • iter + a sequence of one or two values +
  • +
  • arg + optional argument to pass to function. +
  • +
+ + + + + +
+
+ + filter (iter, pred, arg) +
+
+ filter a sequence using a predicate function. + + +

Parameters:

+
    +
  • iter + a sequence of one or two values +
  • +
  • pred + a boolean function; may take two arguments +
  • +
  • arg + optional argument to pass to function. +
  • +
+ + + + + +
+
+ + reduce (fn, iter, initval) +
+
+ 'reduce' a sequence using a binary function. + + +

Parameters:

+
    +
  • fn + func + a function of two arguments +
  • +
  • iter + a sequence +
  • +
  • initval + optional initial value +
  • +
+ + + + +

Usage:

+
    +
  • seq.reduce(operator.add,seq.list{1,2,3,4}) == 10
  • +
  • seq.reduce('-',{1,2,3,4,5}) == -13
  • +
+ +
+
+ + take (iter, n) +
+
+ take the first n values from the sequence. + + +

Parameters:

+
    +
  • iter + a sequence of one or two values +
  • +
  • n + number of items to take +
  • +
+ +

Returns:

+
    + + a sequence of at most n items +
+ + + + +
+
+ + skip (iter, n) +
+
+ skip the first n values of a sequence + + +

Parameters:

+
    +
  • iter + a sequence of one or more values +
  • +
  • n + number of items to skip +
  • +
+ + + + + +
+
+ + enum (iter) +
+
+ a sequence with a sequence count and the original value. + enum(copy(ls)) is a roundabout way of saying ipairs(ls). + + +

Parameters:

+
    +
  • iter + a single or double valued sequence +
  • +
+ +

Returns:

+
    + + sequence of (i,v), i = 1..n and v is from iter. +
+ + + + +
+
+ + mapmethod (iter, name, arg1, arg2) +
+
+ map using a named method over a sequence. + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
  • name + the method name +
  • +
  • arg1 + optional first extra argument +
  • +
  • arg2 + optional second extra argument +
  • +
+ + + + + +
+
+ + last (iter) +
+
+ a sequence of (last,current) values from another sequence. + This will return S(i-1),S(i) if given S(i) + + +

Parameters:

+
    +
  • iter + a sequence +
  • +
+ + + + + +
+
+ + foreach (iter, fn) +
+
+ call the function on each element of the sequence. + + +

Parameters:

+
    +
  • iter + a sequence with up to 3 values +
  • +
  • fn + a function +
  • +
+ + + + + +
+
+ + lines (f, ...) +
+
+ create a wrapped iterator over all lines in the file. + + +

Parameters:

+
    +
  • f + either a filename, file-like object, or 'STDIN' (for standard input) +
  • +
  • ... + for Lua 5.2 only, optional format specifiers, as in io.read. +
  • +
+ +

Returns:

+
    + + a sequence wrapper +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.sip.html b/Data/Libraries/Penlight/docs/libraries/pl.sip.html new file mode 100644 index 0000000..d488b09 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.sip.html @@ -0,0 +1,399 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.sip

+

Simple Input Patterns (SIP).

+

SIP patterns start with '$', then a + one-letter type, and then an optional variable in curly braces.

+ + +
+sip.match('$v=$q','name="dolly"',res)
+==> res=={'name','dolly'}
+sip.match('($q{first},$q{second})','("john","smith")',res)
+==> res=={second='smith',first='john'}
+
+ +

Type names:

+ + +
+v     identifier
+i     integer
+f     floating-point
+q     quoted string
+([{<  match up to closing bracket
+
+ +

See the Guide

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
create_pattern (spec, options)convert a SIP pattern into the equivalent Lua string pattern.
compile (spec, options)convert a SIP pattern into a matching function.
match (spec, line, res, options)match a SIP pattern against a string.
match_at_start (spec, line, res)match a SIP pattern against the start of a string.
fields (spec, f)given a pattern and a file object, return an iterator over the results
pattern (spec, fun)register a match which will be used in the read function.
read (f, matches)enter a loop which applies all registered matches to the input file.
+ +
+
+ + +

Functions

+ +
+
+ + create_pattern (spec, options) +
+
+ convert a SIP pattern into the equivalent Lua string pattern. + + +

Parameters:

+
    +
  • spec + a SIP pattern +
  • +
  • options + a table; only the at_start field is + currently meaningful and ensures that the pattern is anchored + at the start of the string. +
  • +
+ +

Returns:

+
    + + a Lua string pattern. +
+ + + + +
+
+ + compile (spec, options) +
+
+ convert a SIP pattern into a matching function. + The returned function takes two arguments, the line and an empty table. + If the line matched the pattern, then this function returns true + and the table is filled with field-value pairs. + + +

Parameters:

+
    +
  • spec + a SIP pattern +
  • +
  • options + optional table; {at_start=true} ensures that the pattern + is anchored at the start of the string. +
  • +
+ +

Returns:

+
    + + a function if successful, or nil,error +
+ + + + +
+
+ + match (spec, line, res, options) +
+
+ match a SIP pattern against a string. + + +

Parameters:

+
    +
  • spec + a SIP pattern +
  • +
  • line + a string +
  • +
  • res + a table to receive values +
  • +
  • options + (optional) option table +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + match_at_start (spec, line, res) +
+
+ match a SIP pattern against the start of a string. + + +

Parameters:

+
    +
  • spec + a SIP pattern +
  • +
  • line + a string +
  • +
  • res + a table to receive values +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + fields (spec, f) +
+
+ given a pattern and a file object, return an iterator over the results + + +

Parameters:

+
    +
  • spec + a SIP pattern +
  • +
  • f + a file-like object. +
  • +
+ + + + + +
+
+ + pattern (spec, fun) +
+
+ register a match which will be used in the read function. + + +

Parameters:

+
    +
  • spec + string + a SIP pattern +
  • +
  • fun + func + a function to be called with the results of the match +
  • +
+ + + +

See also:

+ + + +
+
+ + read (f, matches) +
+
+ enter a loop which applies all registered matches to the input file. + + +

Parameters:

+
    +
  • f + a file-like object +
  • +
  • matches + array + optional list of {spec,fun} pairs, as for pattern above. +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.strict.html b/Data/Libraries/Penlight/docs/libraries/pl.strict.html new file mode 100644 index 0000000..3c9c0bd --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.strict.html @@ -0,0 +1,270 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.strict

+

Checks uses of undeclared global variables.

+

All global variables must be 'declared' through a regular assignment + (even assigning nil will do) in a main chunk before being used + anywhere or assigned to inside a function. Existing metatables __newindex and __index + metamethods are respected.

+ +

You can set any table to have strict behaviour using strict.module. Creating a new + module with strict.closed_module makes the module immune to monkey-patching, if + you don't wish to encourage monkey business.

+ +

If the global PENLIGHT_NO_GLOBAL_STRICT is defined, then this module won't make the + global environment strict - if you just want to explicitly set table strictness.

+ + +

Functions

+ + + + + + + + + + + + + +
module ([name[, mod[, predeclared]]])make an existing table strict.
make_all_strict (T)make all tables in a table strict.
closed_module (mod, name)make a new module table which is closed to further changes.
+ +
+
+ + +

Functions

+ +
+
+ + module ([name[, mod[, predeclared]]]) +
+
+ make an existing table strict. + + +

Parameters:

+
    +
  • name + string + name of table + (optional) +
  • +
  • mod + tab + the table to protect - if nil then we'll return a new table + (optional) +
  • +
  • predeclared + tab + +
      +
    • table of variables that are to be considered predeclared.
    • +
    + + (optional) +
  • +
+ +

Returns:

+
    + + the given table, or a new table +
+ + + +

Usage:

+
    +
    local M = { hello = "world" }
    +strict.module ("Awesome_Module", M, {
    +  Lua = true,  -- defines allowed keys
    +})
    +
    +assert(M.hello == "world")
    +assert(M.Lua == nil)       -- access allowed, but has no value yet
    +M.Lua = "Rocks"
    +assert(M.Lua == "Rocks")
    +M.not_allowed = "bad boy"  -- throws an error
    +
+ +
+
+ + make_all_strict (T) +
+
+ make all tables in a table strict. + So strict.make_all_strict(_G) prevents monkey-patching + of any global table + + +

Parameters:

+
    +
  • T + tab + the table containing the tables to protect. Table T itself will NOT be protected. +
  • +
+ + + + + +
+
+ + closed_module (mod, name) +
+
+ make a new module table which is closed to further changes. + + +

Parameters:

+
    +
  • mod + tab + module table +
  • +
  • name + string + module name +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.stringio.html b/Data/Libraries/Penlight/docs/libraries/pl.stringio.html new file mode 100644 index 0000000..7505d34 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.stringio.html @@ -0,0 +1,215 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.stringio

+

Reading and writing strings using file-like objects.

+


+ + +
+f = stringio.open(text)
+l1 = f:read()  -- read first line
+n,m = f:read ('*n','*n') -- read two numbers
+for line in f:lines() do print(line) end -- iterate over all lines
+f = stringio.create()
+f:write('hello')
+f:write('dolly')
+assert(f:value(),'hellodolly')
+
+ +

See the Guide.

+ + +

Functions

+ + + + + + + + + +
create ()create a file-like object which can be used to construct a string.
open (s)create a file-like object for reading from a given string.
+ +
+
+ + +

Functions

+ +
+
+ + create () +
+
+ create a file-like object which can be used to construct a string. + The resulting object has an extra value() method for + retrieving the string value. Implements file:write, file:seek, file:lines, + plus an extra writef method which works like utils.printf. + + + + + + +

Usage:

+
    +
    f = create(); f:write('hello, dolly\n'); print(f:value())
    +
+ +
+
+ + open (s) +
+
+ create a file-like object for reading from a given string. + Implements file:read. + + +

Parameters:

+
    +
  • s + string + The input string. +
  • +
+ + + + +

Usage:

+
    +
    fs = open '20 10'; x,y = f:read ('*n','*n'); assert(x == 20 and y == 10)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.stringx.html b/Data/Libraries/Penlight/docs/libraries/pl.stringx.html new file mode 100644 index 0000000..4fd08cd --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.stringx.html @@ -0,0 +1,1239 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.stringx

+

Python-style extended string library.

+

see 3.6.1 of the Python reference. + If you want to make these available as string methods, then say + stringx.import() to bring them into the standard string table.

+ +

See the Guide

+ +

Dependencies: pl.utils

+ + +

String Predicates

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
isalpha (s)does s only contain alphabetic characters?
isdigit (s)does s only contain digits?
isalnum (s)does s only contain alphanumeric characters?
isspace (s)does s only contain spaces?
islower (s)does s only contain lower case characters?
isupper (s)does s only contain upper case characters?
startswith (s, prefix)does s start with prefix or one of prefixes?
endswith (s, suffix)does s end with suffix or one of suffixes?
+

Strings and Lists

+ + + + + + + + + + + + + + + + + +
join (s, seq)concatenate the strings using this string as a delimiter.
splitlines (s[, keep_ends])Split a string into a list of lines.
split (s[, re[, n]])split a string into a list of strings using a delimiter.
expandtabs (s, tabsize)replace all tabs in s with tabsize spaces.
+

Finding and Replacing

+ + + + + + + + + + + + + + + + + +
lfind (s, sub[, first[, last]])find index of first instance of sub in s from the left.
rfind (s, sub[, first[, last]])find index of first instance of sub in s from the right.
replace (s, old, new[, n])replace up to n instances of old by new in the string s.
count (s, sub[, allow_overlap])count all instances of substring in string.
+

Stripping and Justifying

+ + + + + + + + + + + + + + + + + + + + + + + + + +
ljust (s, w[, ch=' '])left-justify s with width w.
rjust (s, w[, ch=' '])right-justify s with width w.
center (s, w[, ch=' '])center-justify s with width w.
lstrip (s[, chrs='%s'])trim any whitespace on the left of s.
rstrip (s[, chrs='%s'])trim any whitespace on the right of s.
strip (s[, chrs='%s'])trim any whitespace on both left and right of s.
+

Partioning Strings

+ + + + + + + + + + + + + + + + + +
splitv (s[, re='%s'])split a string using a pattern.
partition (s, ch)partition the string using first occurance of a delimiter
rpartition (s, ch)partition the string p using last occurance of a delimiter
at (s, idx)return the 'character' at the index.
+

Miscelaneous

+ + + + + + + + + + + + + + + + + +
lines (s)return an iterator over all lines in a string
title (s)inital word letters uppercase ('title case').
shorten (s, w, tail)Return a shortened version of a string.
quote_string (s)Quote the given string and preserve any control or escape characters, such that reloading the string in Lua returns the same result.
+ +
+
+ + +

String Predicates

+ +
+
+ + isalpha (s) +
+
+ does s only contain alphabetic characters? + + +

Parameters:

+ + + + + + +
+
+ + isdigit (s) +
+
+ does s only contain digits? + + +

Parameters:

+ + + + + + +
+
+ + isalnum (s) +
+
+ does s only contain alphanumeric characters? + + +

Parameters:

+ + + + + + +
+
+ + isspace (s) +
+
+ does s only contain spaces? + + +

Parameters:

+ + + + + + +
+
+ + islower (s) +
+
+ does s only contain lower case characters? + + +

Parameters:

+ + + + + + +
+
+ + isupper (s) +
+
+ does s only contain upper case characters? + + +

Parameters:

+ + + + + + +
+
+ + startswith (s, prefix) +
+
+ does s start with prefix or one of prefixes? + + +

Parameters:

+
    +
  • s + string + a string +
  • +
  • prefix + a string or an array of strings +
  • +
+ + + + + +
+
+ + endswith (s, suffix) +
+
+ does s end with suffix or one of suffixes? + + +

Parameters:

+
    +
  • s + string + a string +
  • +
  • suffix + a string or an array of strings +
  • +
+ + + + + +
+
+

Strings and Lists

+ +
+
+ + join (s, seq) +
+
+ concatenate the strings using this string as a delimiter. + Note that the arguments are reversed from string.concat. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • seq + a table of strings or numbers +
  • +
+ + + + +

Usage:

+
    +
    stringx.join(' ', {1,2,3}) == '1 2 3'
    +
+ +
+
+ + splitlines (s[, keep_ends]) +
+
+ Split a string into a list of lines. + "\r", "\n", and "\r\n" are considered line ends. + They are not included in the lines unless keepends is passed. + Terminal line end does not produce an extra line. + Splitting an empty string results in an empty list. + + +

Parameters:

+
    +
  • s + string + the string. +
  • +
  • keep_ends + bool + include line ends. + (optional) +
  • +
+ +

Returns:

+
    + + List of lines +
+ + + + +
+
+ + split (s[, re[, n]]) +
+
+ split a string into a list of strings using a delimiter. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • re + string + a delimiter (defaults to whitespace) + (optional) +
  • +
  • n + int + maximum number of results + (optional) +
  • +
+ +

Returns:

+
    + + List +
+ + + +

Usage:

+
    +
  • #(stringx.split('one two')) == 2
  • +
  • stringx.split('one,two,three', ',') == List{'one','two','three'}
  • +
  • stringx.split('one,two,three', ',', 2) == List{'one','two,three'}
  • +
+ +
+
+ + expandtabs (s, tabsize) +
+
+ replace all tabs in s with tabsize spaces. If not specified, tabsize defaults to 8. + Tab stops will be honored. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • tabsize + int + [opt=8] number of spaces to expand each tab +
  • +
+ +

Returns:

+
    + + expanded string +
+ + + +

Usage:

+
    +
  • stringx.expandtabs('\tone,two,three', 4)   == '    one,two,three'
  • +
  • stringx.expandtabs('  \tone,two,three', 4) == '    one,two,three'
  • +
+ +
+
+

Finding and Replacing

+ +
+
+ + lfind (s, sub[, first[, last]]) +
+
+ find index of first instance of sub in s from the left. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • sub + string + substring +
  • +
  • first + int + first index + (optional) +
  • +
  • last + int + last index + (optional) +
  • +
+ +

Returns:

+
    + + start index, or nil if not found +
+ + + + +
+
+ + rfind (s, sub[, first[, last]]) +
+
+ find index of first instance of sub in s from the right. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • sub + string + substring +
  • +
  • first + int + first index + (optional) +
  • +
  • last + int + last index + (optional) +
  • +
+ +

Returns:

+
    + + start index, or nil if not found +
+ + + + +
+
+ + replace (s, old, new[, n]) +
+
+ replace up to n instances of old by new in the string s. + If n is not present, replace all instances. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • old + string + the target substring +
  • +
  • new + string + the substitution +
  • +
  • n + int + optional maximum number of substitutions + (optional) +
  • +
+ +

Returns:

+
    + + result string +
+ + + + +
+
+ + count (s, sub[, allow_overlap]) +
+
+ count all instances of substring in string. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • sub + string + substring +
  • +
  • allow_overlap + bool + allow matches to overlap + (optional) +
  • +
+ + + + +

Usage:

+
    +
    assert(stringx.count('banana', 'ana') == 1)
    +assert(stringx.count('banana', 'ana', true) == 2)
    +
+ +
+
+

Stripping and Justifying

+ +
+
+ + ljust (s, w[, ch=' ']) +
+
+ left-justify s with width w. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • w + int + width of justification +
  • +
  • ch + string + padding character + (default ' ') +
  • +
+ + + + +

Usage:

+
    +
    stringx.ljust('hello', 10, '*') == '*****hello'
    +
+ +
+
+ + rjust (s, w[, ch=' ']) +
+
+ right-justify s with width w. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • w + int + width of justification +
  • +
  • ch + string + padding character + (default ' ') +
  • +
+ + + + +

Usage:

+
    +
    stringx.rjust('hello', 10, '*') == 'hello*****'
    +
+ +
+
+ + center (s, w[, ch=' ']) +
+
+ center-justify s with width w. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • w + int + width of justification +
  • +
  • ch + string + padding character + (default ' ') +
  • +
+ + + + +

Usage:

+
    +
    stringx.center('hello', 10, '*') == '**hello***'
    +
+ +
+
+ + lstrip (s[, chrs='%s']) +
+
+ trim any whitespace on the left of s. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • chrs + string + default any whitespace character, + but can be a string of characters to be trimmed + (default '%s') +
  • +
+ + + + + +
+
+ + rstrip (s[, chrs='%s']) +
+
+ trim any whitespace on the right of s. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • chrs + string + default any whitespace character, + but can be a string of characters to be trimmed + (default '%s') +
  • +
+ + + + + +
+
+ + strip (s[, chrs='%s']) +
+
+ trim any whitespace on both left and right of s. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • chrs + string + default any whitespace character, + but can be a string of characters to be trimmed + (default '%s') +
  • +
+ + + + + +
+
+

Partioning Strings

+ +
+
+ + splitv (s[, re='%s']) +
+
+ split a string using a pattern. Note that at least one value will be returned! + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • re + string + a Lua string pattern (defaults to whitespace) + (default '%s') +
  • +
+ +

Returns:

+
    + + the parts of the string +
+ + +

See also:

+ + +

Usage:

+
    +
    a,b = line:splitv('=')
    +
+ +
+
+ + partition (s, ch) +
+
+ partition the string using first occurance of a delimiter + + +

Parameters:

+ + +

Returns:

+
    +
  1. + part before ch
  2. +
  3. + ch
  4. +
  5. + part after ch
  6. +
+ + + +

Usage:

+
    +
  • {stringx.partition('a,b,c', ','))} == {'a', ',', 'b,c'}
  • +
  • {stringx.partition('abc', 'x'))} == {'abc', '', ''}
  • +
+ +
+
+ + rpartition (s, ch) +
+
+ partition the string p using last occurance of a delimiter + + +

Parameters:

+ + +

Returns:

+
    +
  1. + part before ch
  2. +
  3. + ch
  4. +
  5. + part after ch
  6. +
+ + + +

Usage:

+
    +
  • {stringx.rpartition('a,b,c', ','))} == {'a,b', ',', 'c'}
  • +
  • {stringx.rpartition('abc', 'x'))} == {'', '', 'abc'}
  • +
+ +
+
+ + at (s, idx) +
+
+ return the 'character' at the index. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • idx + int + an index (can be negative) +
  • +
+ +

Returns:

+
    + + a substring of length 1 if successful, empty string otherwise. +
+ + + + +
+
+

Miscelaneous

+ +
+
+ + lines (s) +
+
+ return an iterator over all lines in a string + + +

Parameters:

+
    +
  • s + string + the string +
  • +
+ +

Returns:

+
    + + an iterator +
+ + + +

Usage:

+
    +
    local line_no = 1
    +for line in stringx.lines(some_text) do
    +  print(line_no, line)
    +  line_no = line_no + 1
    +end
    +
+ +
+
+ + title (s) +
+
+ inital word letters uppercase ('title case'). + Here 'words' mean chunks of non-space characters. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
+ +

Returns:

+
    + + a string with each word's first letter uppercase +
+ + + +

Usage:

+
    +
    stringx.title("hello world") == "Hello World")
    +
+ +
+
+ + shorten (s, w, tail) +
+
+ Return a shortened version of a string. + Fits string within w characters. Removed characters are marked with ellipsis. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • w + int + the maxinum size allowed +
  • +
  • tail + bool + true if we want to show the end of the string (head otherwise) +
  • +
+ + + + +

Usage:

+
    +
  • ('1234567890'):shorten(8) == '12345...'
  • +
  • ('1234567890'):shorten(8, true) == '...67890'
  • +
  • ('1234567890'):shorten(20) == '1234567890'
  • +
+ +
+
+ + quote_string (s) +
+
+ Quote the given string and preserve any control or escape characters, such that reloading the string in Lua returns the same result. + + +

Parameters:

+
    +
  • s + The string to be quoted. +
  • +
+ +

Returns:

+
    + + The quoted string. +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.tablex.html b/Data/Libraries/Penlight/docs/libraries/pl.tablex.html new file mode 100644 index 0000000..2e07080 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.tablex.html @@ -0,0 +1,1980 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.tablex

+

Extended operations on Lua tables.

+

See the Guide

+ +

Dependencies: pl.utils, pl.types

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
size (t)total number of elements in this table.
index_by (tbl, idx)return a list of all values in a table indexed by another list.
transform (fun, t, ...)apply a function to all values of a table, in-place.
range (start, finish[, step=1])generate a table of all numbers in a range.
reduce (fun, t, memo)'reduce' a list using a binary function.
index_map (t)create an index map from a list-like table.
makeset (t)create a set from a list-like table.
union (t1, t2)the union of two map-like tables.
intersection (t1, t2)the intersection of two map-like tables.
count_map (t, cmp)A table where the key/values are the values and value counts of the table.
set (t, val[, i1=1[, i2=#t]])set an array range to a value.
new (n, val)create a new array of specified size with initial value.
clear (t, istart)clear out the contents of a table.
removevalues (t, i1, i2)remove a range of values from a table.
readonly (t)modifies a table to be read only.
+

Copying

+ + + + + + + + + + + + + + + + + + + + + + + + + +
update (t1, t2)copy a table into another, in-place.
copy (t)make a shallow copy of a table
deepcopy (t)make a deep copy of a table, recursively copying all the keys and fields.
icopy (dest, src[, idest=1[, isrc=1[, nsrc=#src]]])copy an array into another one, clearing dest after idest+nsrc, if necessary.
move (dest, src[, idest=1[, isrc=1[, nsrc=#src]]])copy an array into another one.
insertvalues (t[, position], values)insert values into a table.
+

Comparing

+ + + + + + + + + + + + + +
deepcompare (t1, t2[, ignore_mt[, eps]])compare two values.
compare (t1, t2, cmp)compare two arrays using a predicate.
compare_no_order (t1, t2, cmp)compare two list-like tables using an optional predicate, without regard for element order.
+

Finding

+ + + + + + + + + + + + + + + + + +
find (t, val, idx)return the index of a value in a list.
rfind (t, val, idx)return the index of a value in a list, searching from the end.
find_if (t, cmp, arg)return the index (or key) of a value in a table using a comparison function.
search (t, value[, exclude])find a value in a table by recursive search.
+

MappingAndFiltering

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
map (fun, t, ...)apply a function to all values of a table.
imap (fun, t, ...)apply a function to all values of a list.
map_named_method (name, t, ...)apply a named method to values from a table.
map2 (fun, t1, t2, ...)apply a function to values from two tables.
imap2 (fun, t1, t2, ...)apply a function to values from two arrays.
mapn (fun, ..., fun)Apply a function to a number of tables.
pairmap (fun, t, ...)call the function with the key and value pairs from a table.
filter (t, pred, arg)filter an array's values using a predicate function
+

Iterating

+ + + + + + + + + + + + + + + + + +
foreach (t, fun, ...)apply a function to all elements of a table.
foreachi (t, fun, ...)apply a function to all elements of a list-like table in order.
sort (t, f)return an iterator to a table sorted by its keys
sortv (t, f)return an iterator to a table sorted by its values
+

Extraction

+ + + + + + + + + + + + + +
keys (t)return all the keys of a table in arbitrary order.
values (t)return all the values of the table in arbitrary order
sub (t, first, last)Extract a range from a table, like 'string.sub'.
+

Merging

+ + + + + + + + + + + + + +
merge (t1, t2, dup)combine two tables, either as union or intersection.
difference (s1, s2, symm)a new table which is the difference of two tables.
zip (...)return a table where each element is a table of the ith values of an arbitrary + number of tables.
+ +
+
+ + +

Functions

+ +
+
+ + size (t) +
+
+ total number of elements in this table. + Note that this is distinct from #t, which is the number + of values in the array part; this value will always + be greater or equal. The difference gives the size of + the hash part, for practical purposes. Works for any + object with a __pairs metamethod. + + +

Parameters:

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

Returns:

+
    + + the size +
+ + + + +
+
+ + index_by (tbl, idx) +
+
+ return a list of all values in a table indexed by another list. + + +

Parameters:

+
    +
  • tbl + tab + a table +
  • +
  • idx + array + an index table (a list of keys) +
  • +
+ +

Returns:

+
    + + a list-like table +
+ + + +

Usage:

+
    +
  • index_by({10,20,30,40},{2,4}) == {20,40}
  • +
  • index_by({one=1,two=2,three=3},{'one','three'}) == {1,3}
  • +
+ +
+
+ + transform (fun, t, ...) +
+
+ apply a function to all values of a table, in-place. + Any extra arguments are passed to the function. + + +

Parameters:

+
    +
  • fun + func + A function that takes at least one argument +
  • +
  • t + tab + a table +
  • +
  • ... + extra arguments passed to fun +
  • +
+ + + +

See also:

+ + + +
+
+ + range (start, finish[, step=1]) +
+
+ generate a table of all numbers in a range. + This is consistent with a numerical for loop. + + +

Parameters:

+
    +
  • start + int + number +
  • +
  • finish + int + number +
  • +
  • step + int + make this negative for start < finish + (default 1) +
  • +
+ + + + + +
+
+ + reduce (fun, t, memo) +
+
+ 'reduce' a list using a binary function. + + +

Parameters:

+
    +
  • fun + func + a function of two arguments +
  • +
  • t + array + a list-like table +
  • +
  • memo + array + optional initial memo value. Defaults to first value in table. +
  • +
+ +

Returns:

+
    + + the result of the function +
+ + + +

Usage:

+
    +
    reduce('+',{1,2,3,4}) == 10
    +
+ +
+
+ + index_map (t) +
+
+ create an index map from a list-like table. The original values become keys, + and the associated values are the indices into the original list. + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
+ +

Returns:

+
    + + a map-like table +
+ + + + +
+
+ + makeset (t) +
+
+ create a set from a list-like table. A set is a table where the original values + become keys, and the associated values are all true. + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
+ +

Returns:

+
    + + a set (a map-like table) +
+ + + + +
+
+ + union (t1, t2) +
+
+ the union of two map-like tables. + If there are duplicate keys, the second table wins. + + +

Parameters:

+
    +
  • t1 + tab + a table +
  • +
  • t2 + tab + a table +
  • +
+ +

Returns:

+
    + + tab + + + +
+ + +

See also:

+ + + +
+
+ + intersection (t1, t2) +
+
+ the intersection of two map-like tables. + + +

Parameters:

+
    +
  • t1 + tab + a table +
  • +
  • t2 + tab + a table +
  • +
+ +

Returns:

+
    + + tab + + + +
+ + +

See also:

+ + + +
+
+ + count_map (t, cmp) +
+
+ A table where the key/values are the values and value counts of the table. + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
  • cmp + func + a function that defines equality (otherwise uses ==) +
  • +
+ +

Returns:

+
    + + a map-like table +
+ + +

See also:

+ + + +
+
+ + set (t, val[, i1=1[, i2=#t]]) +
+
+ set an array range to a value. If it's a function we use the result + of applying it to the indices. + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
  • val + a value +
  • +
  • i1 + int + start range + (default 1) +
  • +
  • i2 + int + end range + (default #t) +
  • +
+ + + + + +
+
+ + new (n, val) +
+
+ create a new array of specified size with initial value. + + +

Parameters:

+
    +
  • n + int + size +
  • +
  • val + initial value (can be nil, but don't expect # to work!) +
  • +
+ +

Returns:

+
    + + the table +
+ + + + +
+
+ + clear (t, istart) +
+
+ clear out the contents of a table. + + +

Parameters:

+
    +
  • t + array + a list +
  • +
  • istart + optional start position +
  • +
+ + + + + +
+
+ + removevalues (t, i1, i2) +
+
+ remove a range of values from a table. + End of range may be negative. + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
  • i1 + int + start index +
  • +
  • i2 + int + end index +
  • +
+ +

Returns:

+
    + + the table +
+ + + + +
+
+ + readonly (t) +
+
+ modifies a table to be read only. + This only offers weak protection. Tables can still be modified with + table.insert and rawset.

+ +

NOTE: for Lua 5.1 length, pairs and ipairs will not work, since the + equivalent metamethods are only available in Lua 5.2 and newer. + + +

Parameters:

+
    +
  • t + tab + the table +
  • +
+ +

Returns:

+
    + + the table read only (a proxy). +
+ + + + +
+
+

Copying

+ +
+
+ + update (t1, t2) +
+
+ copy a table into another, in-place. + + +

Parameters:

+
    +
  • t1 + tab + destination table +
  • +
  • t2 + tab + source (actually any iterable object) +
  • +
+ +

Returns:

+
    + + first table +
+ + + + +
+
+ + copy (t) +
+
+ make a shallow copy of a table + + +

Parameters:

+
    +
  • t + tab + an iterable source +
  • +
+ +

Returns:

+
    + + new table +
+ + + + +
+
+ + deepcopy (t) +
+
+ make a deep copy of a table, recursively copying all the keys and fields. + This supports cycles in tables; cycles will be reproduced in the copy. + This will also set the copied table's metatable to that of the original. + + +

Parameters:

+
    +
  • t + tab + A table +
  • +
+ +

Returns:

+
    + + new table +
+ + + + +
+
+ + icopy (dest, src[, idest=1[, isrc=1[, nsrc=#src]]]) +
+
+ copy an array into another one, clearing dest after idest+nsrc, if necessary. + + +

Parameters:

+
    +
  • dest + array + a list-like table +
  • +
  • src + array + a list-like table +
  • +
  • idest + int + where to start copying values into destination + (default 1) +
  • +
  • isrc + int + where to start copying values from source + (default 1) +
  • +
  • nsrc + int + number of elements to copy from source + (default #src) +
  • +
+ + + + + +
+
+ + move (dest, src[, idest=1[, isrc=1[, nsrc=#src]]]) +
+
+ copy an array into another one. + + +

Parameters:

+
    +
  • dest + array + a list-like table +
  • +
  • src + array + a list-like table +
  • +
  • idest + int + where to start copying values into destination + (default 1) +
  • +
  • isrc + int + where to start copying values from source + (default 1) +
  • +
  • nsrc + int + number of elements to copy from source + (default #src) +
  • +
+ + + + + +
+
+ + insertvalues (t[, position], values) +
+
+ insert values into a table. + similar to table.insert but inserts values from given table values, + not the object itself, into table t at position pos. + + +

Parameters:

+
    +
  • t + array + the list +
  • +
  • position + int + (default is at end) + (optional) +
  • +
  • values + array + + + +
  • +
+ + + + + +
+
+

Comparing

+ +
+
+ + deepcompare (t1, t2[, ignore_mt[, eps]]) +
+
+ compare two values. + if they are tables, then compare their keys and fields recursively. + + +

Parameters:

+
    +
  • t1 + A value +
  • +
  • t2 + A value +
  • +
  • ignore_mt + bool + if true, ignore __eq metamethod (default false) + (optional) +
  • +
  • eps + number + if defined, then used for any number comparisons + (optional) +
  • +
+ +

Returns:

+
    + + true or false +
+ + + + +
+
+ + compare (t1, t2, cmp) +
+
+ compare two arrays using a predicate. + + +

Parameters:

+
    +
  • t1 + array + an array +
  • +
  • t2 + array + an array +
  • +
  • cmp + func + A comparison function; bool = cmp(t1_value, t2_value) +
  • +
+ +

Returns:

+
    + + true or false +
+ + + +

Usage:

+
    +
    assert(tablex.compare({ 1, 2, 3 }, { 1, 2, 3 }, "=="))
    +
    +assert(tablex.compare(
    +   {1,2,3, hello = "world"},  -- fields are not compared!
    +   {1,2,3}, function(v1, v2) return v1 == v2 end)
    +
+ +
+
+ + compare_no_order (t1, t2, cmp) +
+
+ compare two list-like tables using an optional predicate, without regard for element order. + + +

Parameters:

+
    +
  • t1 + array + a list-like table +
  • +
  • t2 + array + a list-like table +
  • +
  • cmp + A comparison function (may be nil) +
  • +
+ + + + + +
+
+

Finding

+ +
+
+ + find (t, val, idx) +
+
+ return the index of a value in a list. + Like string.find, there is an optional index to start searching, + which can be negative. + + +

Parameters:

+
    +
  • t + array + A list-like table +
  • +
  • val + A value +
  • +
  • idx + int + index to start; -1 means last element,etc (default 1) +
  • +
+ +

Returns:

+
    + + index of value or nil if not found +
+ + + +

Usage:

+
    +
  • find({10,20,30},20) == 2
  • +
  • find({'a','b','a','c'},'a',2) == 3
  • +
+ +
+
+ + rfind (t, val, idx) +
+
+ return the index of a value in a list, searching from the end. + Like string.find, there is an optional index to start searching, + which can be negative. + + +

Parameters:

+
    +
  • t + array + A list-like table +
  • +
  • val + A value +
  • +
  • idx + index to start; -1 means last element,etc (default #t) +
  • +
+ +

Returns:

+
    + + index of value or nil if not found +
+ + + +

Usage:

+
    +
    rfind({10,10,10},10) == 3
    +
+ +
+
+ + find_if (t, cmp, arg) +
+
+ return the index (or key) of a value in a table using a comparison function.

+ +

NOTE: the 2nd return value of this function, the value returned + by the comparison function, has a limitation that it cannot be false. + Because if it is, then it indicates the comparison failed, and the + function will continue the search. See examples. + + +

Parameters:

+
    +
  • t + tab + A table +
  • +
  • cmp + func + A comparison function +
  • +
  • arg + an optional second argument to the function +
  • +
+ +

Returns:

+
    +
  1. + index of value, or nil if not found
  2. +
  3. + value returned by comparison function (cannot be false!)
  4. +
+ + + +

Usage:

+
    +
    -- using an operator
    +local lst = { "Rudolph", true, false, 15 }
    +local idx, cmp_result = tablex.rfind(lst, "==", "Rudolph")
    +assert(idx == 1)
    +assert(cmp_result == true)
    +
    +local idx, cmp_result = tablex.rfind(lst, "==", false)
    +assert(idx == 3)
    +assert(cmp_result == true)       -- looking up 'false' works!
    +
    +-- using a function returning the value looked up
    +local cmp = function(v1, v2) return v1 == v2 and v2 end
    +local idx, cmp_result = tablex.rfind(lst, cmp, "Rudolph")
    +assert(idx == 1)
    +assert(cmp_result == "Rudolph")  -- the value is returned
    +
    +-- NOTE: this fails, since 'false' cannot be returned!
    +local idx, cmp_result = tablex.rfind(lst, cmp, false)
    +assert(idx == nil)               -- looking up 'false' failed!
    +assert(cmp_result == nil)
    +
+ +
+
+ + search (t, value[, exclude]) +
+
+ find a value in a table by recursive search. + + +

Parameters:

+
    +
  • t + tab + the table +
  • +
  • value + the value +
  • +
  • exclude + array + any tables to avoid searching + (optional) +
  • +
+ +

Returns:

+
    + + a fieldspec, e.g. 'a.b' or 'math.sin' +
+ + + +

Usage:

+
    +
    search(_G,math.sin,{package.path}) == 'math.sin'
    +
+ +
+
+

MappingAndFiltering

+ +
+
+ + map (fun, t, ...) +
+
+ apply a function to all values of a table. + This returns a table of the results. + Any extra arguments are passed to the function. + + +

Parameters:

+
    +
  • fun + func + A function that takes at least one argument +
  • +
  • t + tab + A table +
  • +
  • ... + optional arguments +
  • +
+ + + + +

Usage:

+
    +
    map(function(v) return v*v end, {10,20,30,fred=2}) is {100,400,900,fred=4}
    +
+ +
+
+ + imap (fun, t, ...) +
+
+ apply a function to all values of a list. + This returns a table of the results. + Any extra arguments are passed to the function. + + +

Parameters:

+
    +
  • fun + func + A function that takes at least one argument +
  • +
  • t + array + a table (applies to array part) +
  • +
  • ... + optional arguments +
  • +
+ +

Returns:

+
    + + a list-like table +
+ + + +

Usage:

+
    +
    imap(function(v) return v*v end, {10,20,30,fred=2}) is {100,400,900}
    +
+ +
+
+ + map_named_method (name, t, ...) +
+
+ apply a named method to values from a table. + + +

Parameters:

+
    +
  • name + string + the method name +
  • +
  • t + array + a list-like table +
  • +
  • ... + any extra arguments to the method +
  • +
+ +

Returns:

+
    + + a List with the results of the method (1st result only) +
+ + + +

Usage:

+
    +
    local Car = {}
    +Car.__index = Car
    +function Car.new(car)
    +  return setmetatable(car or {}, Car)
    +end
    +Car.speed = 0
    +function Car:faster(increase)
    +  self.speed = self.speed + increase
    +  return self.speed
    +end
    +
    +local ferrari = Car.new{ name = "Ferrari" }
    +local lamborghini = Car.new{ name = "Lamborghini", speed = 50 }
    +local cars = { ferrari, lamborghini }
    +
    +assert(ferrari.speed == 0)
    +assert(lamborghini.speed == 50)
    +tablex.map_named_method("faster", cars, 10)
    +assert(ferrari.speed == 10)
    +assert(lamborghini.speed == 60)
    +
+ +
+
+ + map2 (fun, t1, t2, ...) +
+
+ apply a function to values from two tables. + + +

Parameters:

+
    +
  • fun + func + a function of at least two arguments +
  • +
  • t1 + tab + a table +
  • +
  • t2 + tab + a table +
  • +
  • ... + extra arguments +
  • +
+ +

Returns:

+
    + + a table +
+ + + +

Usage:

+
    +
    map2('+',{1,2,3,m=4},{10,20,30,m=40}) is {11,22,23,m=44}
    +
+ +
+
+ + imap2 (fun, t1, t2, ...) +
+
+ apply a function to values from two arrays. + The result will be the length of the shortest array. + + +

Parameters:

+
    +
  • fun + func + a function of at least two arguments +
  • +
  • t1 + array + a list-like table +
  • +
  • t2 + array + a list-like table +
  • +
  • ... + extra arguments +
  • +
+ + + + +

Usage:

+
    +
    imap2('+',{1,2,3,m=4},{10,20,30,m=40}) is {11,22,23}
    +
+ +
+
+ + mapn (fun, ..., fun) +
+
+ Apply a function to a number of tables. + A more general version of map + The result is a table containing the result of applying that function to the + ith value of each table. Length of output list is the minimum length of all the lists + + +

Parameters:

+
    +
  • fun + A function that takes as many arguments as there are tables +
  • +
  • ... + tab + n tables +
  • +
  • fun + A function that takes as many arguments as there are tables +
  • +
+ + + + +

Usage:

+
    +
  • mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}) is {111,222,333}
  • +
  • mapn(math.max, {1,20,300},{10,2,3},{100,200,100}) is    {100,200,300}
  • +
+ +
+
+ + pairmap (fun, t, ...) +
+
+ call the function with the key and value pairs from a table. + The function can return a value and a key (note the order!). If both + are not nil, then this pair is inserted into the result: if the key already exists, we convert the value for that + key into a table and append into it. If only value is not nil, then it is appended to the result. + + +

Parameters:

+
    +
  • fun + func + A function which will be passed each key and value as arguments, plus any extra arguments to pairmap. +
  • +
  • t + tab + A table +
  • +
  • ... + optional arguments +
  • +
+ + + + +

Usage:

+
    +
  • pairmap(function(k,v) return v end,{fred=10,bonzo=20}) is {10,20} _or_ {20,10}
  • +
  • pairmap(function(k,v) return {k,v},k end,{one=1,two=2}) is {one={'one',1},two={'two',2}}
  • +
+ +
+
+ + filter (t, pred, arg) +
+
+ filter an array's values using a predicate function + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
  • pred + func + a boolean function +
  • +
  • arg + optional argument to be passed as second argument of the predicate +
  • +
+ + + + + +
+
+

Iterating

+ +
+
+ + foreach (t, fun, ...) +
+
+ apply a function to all elements of a table. + The arguments to the function will be the value, + the key and finally any extra arguments passed to this function. + Note that the Lua 5.0 function table.foreach passed the key first. + + +

Parameters:

+
    +
  • t + tab + a table +
  • +
  • fun + func + a function on the elements; function(value, key, ...) +
  • +
  • ... + extra arguments passed to fun +
  • +
+ + + +

See also:

+ + + +
+
+ + foreachi (t, fun, ...) +
+
+ apply a function to all elements of a list-like table in order. + The arguments to the function will be the value, + the index and finally any extra arguments passed to this function + + +

Parameters:

+
    +
  • t + array + a table +
  • +
  • fun + func + a function with at least one argument +
  • +
  • ... + optional arguments +
  • +
+ + + + + +
+
+ + sort (t, f) +
+
+ return an iterator to a table sorted by its keys + + +

Parameters:

+
    +
  • t + tab + the table +
  • +
  • f + func + an optional comparison function (f(x,y) is true if x < y) +
  • +
+ +

Returns:

+
    + + an iterator to traverse elements sorted by the keys +
+ + + +

Usage:

+
    +
    for k,v in tablex.sort(t) do print(k,v) end
    +
+ +
+
+ + sortv (t, f) +
+
+ return an iterator to a table sorted by its values + + +

Parameters:

+
    +
  • t + tab + the table +
  • +
  • f + func + an optional comparison function (f(x,y) is true if x < y) +
  • +
+ +

Returns:

+
    + + an iterator to traverse elements sorted by the values +
+ + + +

Usage:

+
    +
    for k,v in tablex.sortv(t) do print(k,v) end
    +
+ +
+
+

Extraction

+ +
+
+ + keys (t) +
+
+ return all the keys of a table in arbitrary order. + + +

Parameters:

+
    +
  • t + tab + A table +
  • +
+ + + + + +
+
+ + values (t) +
+
+ return all the values of the table in arbitrary order + + +

Parameters:

+
    +
  • t + tab + A table +
  • +
+ + + + + +
+
+ + sub (t, first, last) +
+
+ Extract a range from a table, like 'string.sub'. + If first or last are negative then they are relative to the end of the list + eg. sub(t,-2) gives last 2 entries in a list, and + sub(t,-4,-2) gives from -4th to -2nd + + +

Parameters:

+
    +
  • t + array + a list-like table +
  • +
  • first + int + An index +
  • +
  • last + int + An index +
  • +
+ +

Returns:

+
    + + a new List +
+ + + + +
+
+

Merging

+ +
+
+ + merge (t1, t2, dup) +
+
+ combine two tables, either as union or intersection. Corresponds to + set operations for sets () but more general. Not particularly + useful for list-like tables. + + +

Parameters:

+
    +
  • t1 + tab + a table +
  • +
  • t2 + tab + a table +
  • +
  • dup + bool + true for a union, false for an intersection. +
  • +
+ + + +

See also:

+ + +

Usage:

+
    +
  • merge({alice=23,fred=34},{bob=25,fred=34}) is {fred=34}
  • +
  • merge({alice=23,fred=34},{bob=25,fred=34},true) is {bob=25,fred=34,alice=23}
  • +
+ +
+
+ + difference (s1, s2, symm) +
+
+ a new table which is the difference of two tables. + With sets (where the values are all true) this is set difference and + symmetric difference depending on the third parameter. + + +

Parameters:

+
    +
  • s1 + tab + a map-like table or set +
  • +
  • s2 + tab + a map-like table or set +
  • +
  • symm + bool + symmetric difference (default false) +
  • +
+ +

Returns:

+
    + + a map-like table or set +
+ + + + +
+
+ + zip (...) +
+
+ return a table where each element is a table of the ith values of an arbitrary + number of tables. It is equivalent to a matrix transpose. + + +

Parameters:

+
    +
  • ... + array + arrays to be zipped +
  • +
+ + + + +

Usage:

+
    +
    zip({10,20,30},{100,200,300}) is {{10,100},{20,200},{30,300}}
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.template.html b/Data/Libraries/Penlight/docs/libraries/pl.template.html new file mode 100644 index 0000000..c2ac2c0 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.template.html @@ -0,0 +1,336 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.template

+

A template preprocessor.

+

Originally by Ricki Lake

+ +

There are two rules:

+ +
    +
  • lines starting with # are Lua
  • +
  • otherwise, $(expr) is the result of evaluating expr
  • +
+ +

Example:

+ + +
+#  for i = 1,3 do
+   $(i) Hello, Word!
+#  end
+===>
+1 Hello, Word!
+2 Hello, Word!
+3 Hello, Word!
+
+ +

Other escape characters can be used, when the defaults conflict + with the output language.

+ + +
+> for _,n in pairs{'one','two','three'} do
+static int l_${n} (luaState *state);
+> end
+
+ +

See the Guide.

+ +

Dependencies: pl.utils

+ + +

Functions

+ + + + + + + + + + + + + +
substitute (str[, env])expand the template using the specified environment.
ct:render ([env[, parent[, db]]])executes the previously compiled template and renders it.
compile (str[, opts])compiles the template.
+ +
+
+ + +

Functions

+ +
+
+ + substitute (str[, env]) +
+
+ +

expand the template using the specified environment. + This function will compile and render the template. For more performant + recurring usage use the two step approach by using compile and ct:render. + There are six special fields in the environment table env

+ +
    +
  • _parent: continue looking up in this table (e.g. _parent=_G).
  • +
  • _brackets: bracket pair that wraps inline Lua expressions, default is '()'.
  • +
  • _escape: character marking Lua lines, default is '#'
  • +
  • _inline_escape: character marking inline Lua expression, default is '$'.
  • +
  • _chunk_name: chunk name for loaded templates, used if there + is an error in Lua code. Default is 'TMP'.
  • +
  • _debug: if truthy, the generated code will be printed upon a render error
  • +
+ + + + +

Parameters:

+
    +
  • str + string + the template string +
  • +
  • env + tab + the environment + (optional) +
  • +
+ +

Returns:

+
    + + rendered template + nil + source_code, or nil + error + source_code. The last + return value (source_code) is only returned if the debug option is used. +
+ + + + +
+
+ + ct:render ([env[, parent[, db]]]) +
+
+ executes the previously compiled template and renders it. + + +

Parameters:

+
    +
  • env + tab + the environment. + (optional) +
  • +
  • parent + tab + continue looking up in this table (e.g. parent=_G). + (optional) +
  • +
  • db + bool + if thruthy, it will print the code upon a render error + (provided the template was compiled with the debug option). + (optional) +
  • +
+ +

Returns:

+
    + + rendered template + nil + source_code, or nil + error + source_code. The last return value + (source_code) is only returned if the template was compiled with the debug option. +
+ + + +

Usage:

+
    +
    local ct, err = template.compile(my_template)
    +local rendered , err = ct:render(my_env, parent)
    +
+ +
+
+ + compile (str[, opts]) +
+
+ +

compiles the template. + Returns an object that can repeatedly be rendered without parsing/compiling + the template again. + The options passed in the opts table support the following options:

+ +
    +
  • chunk_name: chunk name for loaded templates, used if there + is an error in Lua code. Default is 'TMP'.
  • +
  • escape: character marking Lua lines, default is '#'
  • +
  • inline_escape: character marking inline Lua expression, default is '$'.
  • +
  • inline_brackets: bracket pair that wraps inline Lua expressions, default is '()'.
  • +
  • newline: string to replace newline characters, default is nil (not replacing newlines).
  • +
  • debug: if truthy, the generated source code will be retained within the compiled template object, default is nil.
  • +
+ + + + +

Parameters:

+
    +
  • str + string + the template string +
  • +
  • opts + tab + the compilation options to use + (optional) +
  • +
+ +

Returns:

+
    + + template object, or nil + error + source_code +
+ + + +

Usage:

+
    +
    local ct, err = template.compile(my_template)
    +local rendered , err = ct:render(my_env, parent)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.test.html b/Data/Libraries/Penlight/docs/libraries/pl.test.html new file mode 100644 index 0000000..72aff1d --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.test.html @@ -0,0 +1,445 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.test

+

Useful test utilities.

+

+ + + +

+test.asserteq({1,2},{1,2}) -- can compare tables
+test.asserteq(1.2,1.19,0.02) -- compare FP numbers within precision
+T = test.tuple -- used for comparing multiple results
+test.asserteq(T(string.find(" me","me")),T(2,3))
+
+ +

Dependencies: pl.utils, pl.tablex, pl.pretty, pl.path, debug

+

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
error_handler (file, line, got_text, needed_text, msg)error handling for test results.
complain (x, y, msg, where)general test complain message.
asserteq (x, y, eps, where)like assert, except takes two arguments that must be equal and can be tables.
assertmatch (s1, s2, where)assert that the first string matches the second.
assertraise (fn, e, where)assert that the function raises a particular error.
asserteq2 (x1, x2, y1, y2, where)a version of asserteq that takes two pairs of values.
tuple (...)encode an arbitrary argument list as a tuple.
timer (msg, n, fun, ...)Time a function.
+ +
+
+ + +

Functions

+ +
+
+ + error_handler (file, line, got_text, needed_text, msg) +
+
+ error handling for test results. + By default, this writes to stderr and exits the program. + Re-define this function to raise an error and/or redirect output + + +

Parameters:

+
    +
  • file + + + +
  • +
  • line + + + +
  • +
  • got_text + + + +
  • +
  • needed_text + + + +
  • +
  • msg + + + +
  • +
+ + + + + +
+
+ + complain (x, y, msg, where) +
+
+ general test complain message. + Useful for composing new test functions (see tests/tablex.lua for an example) + + +

Parameters:

+
    +
  • x + a value +
  • +
  • y + value to compare first value against +
  • +
  • msg + message +
  • +
  • where + extra level offset for errors +
  • +
+ + + + + +
+
+ + asserteq (x, y, eps, where) +
+
+ like assert, except takes two arguments that must be equal and can be tables. + If they are plain tables, it will use tablex.deepcompare. + + +

Parameters:

+
    +
  • x + any value +
  • +
  • y + a value equal to x +
  • +
  • eps + an optional tolerance for numerical comparisons +
  • +
  • where + extra level offset +
  • +
+ + + + + +
+
+ + assertmatch (s1, s2, where) +
+
+ assert that the first string matches the second. + + +

Parameters:

+
    +
  • s1 + a string +
  • +
  • s2 + a string +
  • +
  • where + extra level offset +
  • +
+ + + + + +
+
+ + assertraise (fn, e, where) +
+
+ assert that the function raises a particular error. + + +

Parameters:

+
    +
  • fn + a function or a table of the form {function,arg1,...} +
  • +
  • e + a string to match the error against +
  • +
  • where + extra level offset +
  • +
+ + + + + +
+
+ + asserteq2 (x1, x2, y1, y2, where) +
+
+ a version of asserteq that takes two pairs of values. + x1==y1 and x2==y2 must be true. Useful for functions that naturally + return two values. + + +

Parameters:

+
    +
  • x1 + any value +
  • +
  • x2 + any value +
  • +
  • y1 + any value +
  • +
  • y2 + any value +
  • +
  • where + extra level offset +
  • +
+ + + + + +
+
+ + tuple (...) +
+
+ encode an arbitrary argument list as a tuple. + This can be used to compare to other argument lists, which is + very useful for testing functions which return a number of values. + Unlike regular array-like tables ('sequences') they may contain nils. + Tuples understand equality and know how to print themselves out. + The # operator is defined to be the size, irrespecive of any nils, + and there is an unpack method. + + +

Parameters:

+
    +
  • ... + + + +
  • +
+ + + + +

Usage:

+
    +
    asserteq(tuple( ('ab'):find 'a'), tuple(1,1))
    +
+ +
+
+ + timer (msg, n, fun, ...) +
+
+ Time a function. Call the function a given number of times, and report the number of seconds taken, + together with a message. Any extra arguments will be passed to the function. + + +

Parameters:

+
    +
  • msg + string + a descriptive message +
  • +
  • n + int + number of times to call the function +
  • +
  • fun + func + the function +
  • +
  • ... + optional arguments to fun +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.text.html b/Data/Libraries/Penlight/docs/libraries/pl.text.html new file mode 100644 index 0000000..77b7db1 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.text.html @@ -0,0 +1,381 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.text

+

Text processing utilities.

+

This provides a Template class (modeled after the same from the Python + libraries, see string.Template). It also provides similar functions to those + found in the textwrap module.

+ +

See the Guide.

+ +

Calling text.format_operator() overloads the % operator for strings to give Python/Ruby style formated output. + This is extended to also do template-like substitution for map-like data.

+ + +
+> require 'pl.text'.format_operator()
+> = '%s = %5.3f' % {'PI',math.pi}
+PI = 3.142
+> = '$name = $value' % {name='dog',value='Pluto'}
+dog = Pluto
+
+ +

Dependencies: pl.utils, pl.types

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
indent (s, n, ch)indent a multiline string.
dedent (s)dedent a multiline string by removing any initial indent.
wrap (s, width)format a paragraph into lines so that they fit into a line width.
fill (s, width)format a paragraph so that it fits into a line width.
Template:substitute (tbl)substitute values into a template, throwing an error.
Template:safe_substitute (tbl)substitute values into a template.
Template:indent_substitute (tbl)substitute values into a template, preserving indentation.
+ +
+
+ + +

Functions

+ +
+
+ + indent (s, n, ch) +
+
+ indent a multiline string. + + +

Parameters:

+
    +
  • s + the string +
  • +
  • n + the size of the indent +
  • +
  • ch + the character to use when indenting (default ' ') +
  • +
+ +

Returns:

+
    + + indented string +
+ + + + +
+
+ + dedent (s) +
+
+ dedent a multiline string by removing any initial indent. + useful when working with [[..]] strings. + + +

Parameters:

+
    +
  • s + the string +
  • +
+ +

Returns:

+
    + + a string with initial indent zero. +
+ + + + +
+
+ + wrap (s, width) +
+
+ format a paragraph into lines so that they fit into a line width. + It will not break long words, so lines can be over the length + to that extent. + + +

Parameters:

+
    +
  • s + the string +
  • +
  • width + the margin width, default 70 +
  • +
+ +

Returns:

+
    + + a list of lines (List object) +
+ + +

See also:

+ + + +
+
+ + fill (s, width) +
+
+ format a paragraph so that it fits into a line width. + + +

Parameters:

+
    +
  • s + the string +
  • +
  • width + the margin width, default 70 +
  • +
+ +

Returns:

+
    + + a string +
+ + +

See also:

+ + + +
+
+ + Template:substitute (tbl) +
+
+ substitute values into a template, throwing an error. + This will throw an error if no name is found. + + +

Parameters:

+
    +
  • tbl + a table of name-value pairs. +
  • +
+ + + + + +
+
+ + Template:safe_substitute (tbl) +
+
+ substitute values into a template. + This version just passes unknown names through. + + +

Parameters:

+
    +
  • tbl + a table of name-value pairs. +
  • +
+ + + + + +
+
+ + Template:indent_substitute (tbl) +
+
+ substitute values into a template, preserving indentation.
+ If the value is a multiline string or a template, it will insert + the lines at the correct indentation.
+ Furthermore, if a template, then that template will be subsituted + using the same table. + + +

Parameters:

+
    +
  • tbl + a table of name-value pairs. +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.types.html b/Data/Libraries/Penlight/docs/libraries/pl.types.html new file mode 100644 index 0000000..252005e --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.types.html @@ -0,0 +1,475 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.types

+

Dealing with Detailed Type Information

+

+ +

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
is_callable (obj)is the object either a function or a callable object?.
is_type (obj, tp)is the object of the specified type?.
type (obj)a string representation of a type.
is_integer (x)is this number an integer?
is_empty (o, ignore_spaces)Check if the object is "empty".
is_indexable (val)is an object 'array-like'?
is_iterable (val)can an object be iterated over with pairs?
is_writeable (val)can an object accept new key/pair values?
to_bool (o[, true_strs[, check_objs]])Convert to a boolean value.
+ +
+
+ + +

Functions

+ +
+
+ + is_callable (obj) +
+
+ is the object either a function or a callable object?. + + +

Parameters:

+
    +
  • obj + Object to check. +
  • +
+ + + + + +
+
+ + is_type (obj, tp) +
+
+ is the object of the specified type?. + If the type is a string, then use type, otherwise compare with metatable.

+ +

NOTE: this function is imported from utils.is_type. + + +

Parameters:

+
    +
  • obj + An object to check +
  • +
  • tp + The expected type +
  • +
+ + + +

See also:

+ + + +
+
+ + type (obj) +
+
+ a string representation of a type. + For tables and userdata with metatables, we assume that the metatable has a _name + field. If the field is not present it will return 'unknown table' or + 'unknown userdata'. + Lua file objects return the type 'file'. + + +

Parameters:

+
    +
  • obj + an object +
  • +
+ +

Returns:

+
    + + a string like 'number', 'table', 'file' or 'List' +
+ + + + +
+
+ + is_integer (x) +
+
+ is this number an integer? + + +

Parameters:

+
    +
  • x + a number +
  • +
+ +

Returns:

+
    + + boolean +
+ +

Raises:

+ error if x is not a number + + + +
+
+ + is_empty (o, ignore_spaces) +
+
+ +

Check if the object is "empty". + An object is considered empty if it is:

+ +
    +
  • nil
  • +
  • a table without any items (key-value pairs or indexes)
  • +
  • a string with no content ("")
  • +
  • not a nil/table/string
  • +
+ + + +

Parameters:

+
    +
  • o + The object to check if it is empty. +
  • +
  • ignore_spaces + If the object is a string and this is true the string is + considered empty if it only contains spaces. +
  • +
+ +

Returns:

+
    + + true if the object is empty, otherwise a falsy value. +
+ + + + +
+
+ + is_indexable (val) +
+
+ is an object 'array-like'? + An object is array like if:

+ +
    +
  • it is a table, or
  • +
  • it has a metatable with __len and __index methods
  • +
+ +

NOTE: since __len is 5.2+, on 5.1 is usually returns false for userdata + + +

Parameters:

+
    +
  • val + any value. +
  • +
+ +

Returns:

+
    + + true if the object is array-like, otherwise a falsy value. +
+ + + + +
+
+ + is_iterable (val) +
+
+ can an object be iterated over with pairs? + An object is iterable if:

+ +
    +
  • it is a table, or
  • +
  • it has a metatable with a __pairs meta method
  • +
+ +

NOTE: since __pairs is 5.2+, on 5.1 is usually returns false for userdata + + +

Parameters:

+
    +
  • val + any value. +
  • +
+ +

Returns:

+
    + + true if the object is iterable, otherwise a falsy value. +
+ + + + +
+
+ + is_writeable (val) +
+
+ +

can an object accept new key/pair values? + An object is iterable if:

+ +
    +
  • it is a table, or
  • +
  • it has a metatable with a __newindex meta method
  • +
+ + + + +

Parameters:

+
    +
  • val + any value. +
  • +
+ +

Returns:

+
    + + true if the object is writeable, otherwise a falsy value. +
+ + + + +
+
+ + to_bool (o[, true_strs[, check_objs]]) +
+
+ +

Convert to a boolean value. + True values are:

+ +
    +
  • boolean: true.
  • +
  • string: 'yes', 'y', 'true', 't', '1' or additional strings specified by true_strs.
  • +
  • number: Any non-zero value.
  • +
  • table: Is not empty and check_objs is true.
  • +
  • everything else: Is not nil and check_objs is true.
  • +
+ + + + +

Parameters:

+
    +
  • o + The object to evaluate. +
  • +
  • true_strs + optional Additional strings that when matched should evaluate to true. Comparison is case insensitive. + This should be a List of strings. E.g. "ja" to support German. + (optional) +
  • +
  • check_objs + True if objects should be evaluated. + (optional) +
  • +
+ +

Returns:

+
    + + true if the input evaluates to true, otherwise false. +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.url.html b/Data/Libraries/Penlight/docs/libraries/pl.url.html new file mode 100644 index 0000000..7c97371 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.url.html @@ -0,0 +1,212 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.url

+

Python-style URL quoting library.

+

+ +

+ + +

Functions

+ + + + + + + + + +
quote (s, quote_plus)Quote the url, replacing special characters using the '%xx' escape.
unquote (s)Unquote the url, replacing '%xx' escapes and plus signs.
+ +
+
+ + +

Functions

+ +
+
+ + quote (s, quote_plus) +
+
+ Quote the url, replacing special characters using the '%xx' escape. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
  • quote_plus + bool + Also escape slashes and replace spaces by plus signs. +
  • +
+ +

Returns:

+
    + + The quoted string, or if s wasn't a string, just plain unaltered s. +
+ + + + +
+
+ + unquote (s) +
+
+ Unquote the url, replacing '%xx' escapes and plus signs. + + +

Parameters:

+
    +
  • s + string + the string +
  • +
+ +

Returns:

+
    + + The unquoted string, or if s wasn't a string, just plain unaltered s. +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.utils.html b/Data/Libraries/Penlight/docs/libraries/pl.utils.html new file mode 100644 index 0000000..ee1773a --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.utils.html @@ -0,0 +1,1384 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.utils

+

Generally useful routines.

+

See the Guide.

+ +

Dependencies: pl.compat, all exported fields and functions from + pl.compat are also available in this module.

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pack (...)pack an argument list into a table.
unpack (t[, i[, t]])unpack a table and return its contents.
printf (fmt, ...)print an arbitrary number of arguments using a format.
fprintf (f, fmt, ...)write an arbitrary number of arguments to a file using a format.
import (t, T)take a table and 'inject' it into the local namespace.
choose (cond, value1, value2)return either of two values, depending on a condition.
array_tostring (t[, temp[, tostr]])convert an array of values to strings.
is_type (obj, tp)is the object of the specified type?
+

Tables

+ + + + + + + + + +
patternsSome standard patterns
stdmtStandard meta-tables as used by other Penlight modules
+

Error handling

+ + + + + + + + + + + + + + + + + + + + + +
assert_arg (n, val, tp, verify, msg, lev)assert that the given argument is in fact of the correct type.
function_arg (idx, f, msg)process a function argument.
assert_string (n, val)assert the common case that the argument is a string.
on_error (mode)control the error strategy used by Penlight.
raise (err)used by Penlight functions to return errors.
+

File handling

+ + + + + + + + + + + + + +
readfile (filename, is_bin)return the contents of a file as a string
writefile (filename, str, is_bin)write a string to a file
readlines (filename)return the contents of a file as a list of lines
+

OS functions

+ + + + + + + + + + + + + +
executeex (cmd, bin)execute a shell command and return the output.
quote_arg (argument)Quote and escape an argument of a command.
quit ([code], msg, ...)error out of this program gracefully.
+

String functions

+ + + + + + + + + + + + + +
escape (s)escape any Lua 'magic' characters in a string
split (s, re, plain, n)split a string into a list of strings separated by a delimiter.
splitv (s, re, plain, n)split a string into a number of return values.
+

Functional

+ + + + + + + + + + + + + + + + + + + + + +
memoize (func)'memoize' a function (cache returned value for next call).
add_function_factory (mt, fun)associate a function factory with a type.
string_lambda (lf)an anonymous function as a string.
bind1 (fn, p)bind the first argument of the function to a value.
bind2 (fn, p)bind the second argument of the function to a value.
+

Deprecation

+ + + + + + + + + +
set_deprecation_func (func)Sets a deprecation warning function.
raise_deprecation (opts)raises a deprecation warning.
+ +
+
+ + +

Functions

+ +
+
+ + pack (...) +
+
+ pack an argument list into a table. + + +

Parameters:

+
    +
  • ... + any arguments +
  • +
+ +

Returns:

+
    + + a table with field n set to the length +
+ + +

See also:

+ + + +
+
+ + unpack (t[, i[, t]]) +
+
+ unpack a table and return its contents.

+ +

NOTE: this implementation differs from the Lua implementation in the way + that this one DOES honor the n field in the table t, such that it is 'nil-safe'. + + +

Parameters:

+
    +
  • t + index of the last element to unpack, defaults to t.n or #t + (optional) +
  • +
  • i + index from which to start unpacking, defaults to 1 + (optional) +
  • +
  • t + index of the last element to unpack, defaults to t.n or #t + (optional) +
  • +
+ +

Returns:

+
    + + multiple return values from the table +
+ + +

See also:

+ + +

Usage:

+
    +
    local t = table.pack(nil, nil, nil, 4)
    +local a, b, c, d = table.unpack(t)   -- this unpack is NOT nil-safe, so d == nil
    +
    +local a, b, c, d = utils.unpack(t)   -- this is nil-safe, so d == 4
    +
+ +
+
+ + printf (fmt, ...) +
+
+ print an arbitrary number of arguments using a format. + Output will be sent to stdout. + + +

Parameters:

+
    +
  • fmt + The format (see string.format) +
  • +
  • ... + Extra arguments for format +
  • +
+ + + + + +
+
+ + fprintf (f, fmt, ...) +
+
+ write an arbitrary number of arguments to a file using a format. + + +

Parameters:

+
    +
  • f + File handle to write to. +
  • +
  • fmt + The format (see string.format). +
  • +
  • ... + Extra arguments for format +
  • +
+ + + + + +
+
+ + import (t, T) +
+
+ take a table and 'inject' it into the local namespace. + + +

Parameters:

+
    +
  • t + The table (table), or module name (string), defaults to this utils module table +
  • +
  • T + An optional destination table (defaults to callers environment) +
  • +
+ + + + + +
+
+ + choose (cond, value1, value2) +
+
+ return either of two values, depending on a condition. + + +

Parameters:

+
    +
  • cond + A condition +
  • +
  • value1 + Value returned if cond is truthy +
  • +
  • value2 + Value returned if cond is falsy +
  • +
+ + + + + +
+
+ + array_tostring (t[, temp[, tostr]]) +
+
+ convert an array of values to strings. + + +

Parameters:

+
    +
  • t + a list-like table +
  • +
  • temp + (table) buffer to use, otherwise allocate + (optional) +
  • +
  • tostr + custom tostring function, called with (value,index). Defaults to tostring. + (optional) +
  • +
+ +

Returns:

+
    + + the converted buffer +
+ + + + +
+
+ + is_type (obj, tp) +
+
+ is the object of the specified type? + If the type is a string, then use type, otherwise compare with metatable + + +

Parameters:

+
    +
  • obj + An object to check +
  • +
  • tp + String of what type it should be +
  • +
+ +

Returns:

+
    + + boolean +
+ + + +

Usage:

+
    +
    utils.is_type("hello world", "string")   --> true
    +-- or check metatable
    +local my_mt = {}
    +local my_obj = setmetatable(my_obj, my_mt)
    +utils.is_type(my_obj, my_mt)  --> true
    +
+ +
+
+

Tables

+ +
+
+ + patterns +
+
+ Some standard patterns + + +

Fields:

+
    +
  • FLOAT + floating point number +
  • +
  • INTEGER + integer number +
  • +
  • IDEN + identifier +
  • +
  • FILE + file +
  • +
+ + + + + +
+
+ + stdmt +
+
+ Standard meta-tables as used by other Penlight modules + + +

Fields:

+
    +
  • List + the List metatable +
  • +
  • Map + the Map metatable +
  • +
  • Set + the Set metatable +
  • +
  • MultiMap + the MultiMap metatable +
  • +
+ + + + + +
+
+

Error handling

+ +
+
+ + assert_arg (n, val, tp, verify, msg, lev) +
+
+ assert that the given argument is in fact of the correct type. + + +

Parameters:

+
    +
  • n + argument index +
  • +
  • val + the value +
  • +
  • tp + the type +
  • +
  • verify + an optional verification function +
  • +
  • msg + an optional custom message +
  • +
  • lev + optional stack position for trace, default 2 +
  • +
+ +

Returns:

+
    + + the validated value +
+ +

Raises:

+ if val is not the correct type + + +

Usage:

+
    +
    local param1 = assert_arg(1,"hello",'table')  --> error: argument 1 expected a 'table', got a 'string'
    +local param4 = assert_arg(4,'!@#$%^&*','string',path.isdir,'not a directory')
    +     --> error: argument 4: '!@#$%^&*' not a directory
    +
+ +
+
+ + function_arg (idx, f, msg) +
+
+ process a function argument. + This is used throughout Penlight and defines what is meant by a function: + Something that is callable, or an operator string as defined by pl.operator, + such as '>' or '#'. If a function factory has been registered for the type, it will + be called to get the function. + + +

Parameters:

+
    +
  • idx + argument index +
  • +
  • f + a function, operator string, or callable object +
  • +
  • msg + optional error message +
  • +
+ +

Returns:

+
    + + a callable +
+ +

Raises:

+ if idx is not a number or if f is not callable + + + +
+
+ + assert_string (n, val) +
+
+ assert the common case that the argument is a string. + + +

Parameters:

+
    +
  • n + argument index +
  • +
  • val + a value that must be a string +
  • +
+ +

Returns:

+
    + + the validated value +
+ +

Raises:

+ val must be a string + + +

Usage:

+
    +
    local val = 42
    +local param2 = utils.assert_string(2, val) --> error: argument 2 expected a 'string', got a 'number'
    +
+ +
+
+ + on_error (mode) +
+
+ +

control the error strategy used by Penlight. + This is a global setting that controls how utils.raise behaves:

+ +
    +
  • 'default': return nil + error (this is the default)
  • +
  • 'error': throw a Lua error
  • +
  • 'quit': exit the program
  • +
+ + + + +

Parameters:

+
    +
  • mode + either 'default', 'quit' or 'error' +
  • +
+ + + +

See also:

+ + + +
+
+ + raise (err) +
+
+ used by Penlight functions to return errors. Its global behaviour is controlled + by utils.on_error. + To use this function you MUST use it in conjunction with return, since it might + return nil + error. + + +

Parameters:

+
    +
  • err + the error string. +
  • +
+ + + +

See also:

+ + +

Usage:

+
    +
    if some_condition then
    +  return utils.raise("some condition was not met")  -- MUST use 'return'!
    +end
    +
+ +
+
+

File handling

+ +
+
+ + readfile (filename, is_bin) +
+
+ return the contents of a file as a string + + +

Parameters:

+
    +
  • filename + The file path +
  • +
  • is_bin + open in binary mode +
  • +
+ +

Returns:

+
    + + file contents +
+ + + + +
+
+ + writefile (filename, str, is_bin) +
+
+ write a string to a file + + +

Parameters:

+
    +
  • filename + The file path +
  • +
  • str + The string +
  • +
  • is_bin + open in binary mode +
  • +
+ +

Returns:

+
    +
  1. + true or nil
  2. +
  3. + error message
  4. +
+ +

Raises:

+ error if filename or str aren't strings + + + +
+
+ + readlines (filename) +
+
+ return the contents of a file as a list of lines + + +

Parameters:

+
    +
  • filename + The file path +
  • +
+ +

Returns:

+
    + + file contents as a table +
+ +

Raises:

+ error if filename is not a string + + + +
+
+

OS functions

+ +
+
+ + executeex (cmd, bin) +
+
+ execute a shell command and return the output. + This function redirects the output to tempfiles and returns the content of those files. + + +

Parameters:

+
    +
  • cmd + a shell command +
  • +
  • bin + boolean, if true, read output as binary file +
  • +
+ +

Returns:

+
    +
  1. + true if successful
  2. +
  3. + actual return code
  4. +
  5. + stdout output (string)
  6. +
  7. + errout output (string)
  8. +
+ + + + +
+
+ + quote_arg (argument) +
+
+ Quote and escape an argument of a command. + Quotes a single (or list of) argument(s) of a command to be passed + to os.execute, pl.utils.execute or pl.utils.executeex. + + +

Parameters:

+
    +
  • argument + (string or table/list) the argument to quote. If a list then + all arguments in the list will be returned as a single string quoted. +
  • +
+ +

Returns:

+
    + + quoted and escaped argument. +
+ + + +

Usage:

+
    +
    local options = utils.quote_arg {
    +    "-lluacov",
    +    "-e",
    +    "utils = print(require('pl.utils')._VERSION",
    +}
    +-- returns: -lluacov -e 'utils = print(require('\''pl.utils'\'')._VERSION'
    +
+ +
+
+ + quit ([code], msg, ...) +
+
+ error out of this program gracefully. + + +

Parameters:

+
    +
  • code + The exit code, defaults to -1 if omitted + (optional) +
  • +
  • msg + The exit message will be sent to stderr (will be formatted with the extra parameters) +
  • +
  • ... + extra arguments for message's format' +
  • +
+ + + +

See also:

+ + +

Usage:

+
    +
    utils.quit(-1, "Error '%s' happened", "42")
    +-- is equivalent to
    +utils.quit("Error '%s' happened", "42")  --> Error '42' happened
    +
+ +
+
+

String functions

+ +
+
+ + escape (s) +
+
+ escape any Lua 'magic' characters in a string + + +

Parameters:

+
    +
  • s + The input string +
  • +
+ + + + + +
+
+ + split (s, re, plain, n) +
+
+ split a string into a list of strings separated by a delimiter. + + +

Parameters:

+
    +
  • s + The input string +
  • +
  • re + optional A Lua string pattern; defaults to '%s+' +
  • +
  • plain + optional If truthy don't use Lua patterns +
  • +
  • n + optional maximum number of elements (if there are more, the last will remian un-split) +
  • +
+ +

Returns:

+
    + + a list-like table +
+ +

Raises:

+ error if s is not a string + +

See also:

+ + + +
+
+ + splitv (s, re, plain, n) +
+
+ split a string into a number of return values. + Identical to split but returns multiple sub-strings instead of + a single list of sub-strings. + + +

Parameters:

+
    +
  • s + the string +
  • +
  • re + A Lua string pattern; defaults to '%s+' +
  • +
  • plain + don't use Lua patterns +
  • +
  • n + optional maximum number of splits +
  • +
+ +

Returns:

+
    + + n values +
+ + +

See also:

+ + +

Usage:

+
    +
    first,next = splitv('user=jane=doe','=', false, 2)
    +assert(first == "user")
    +assert(next == "jane=doe")
    +
+ +
+
+

Functional

+ +
+
+ + memoize (func) +
+
+ 'memoize' a function (cache returned value for next call). + This is useful if you have a function which is relatively expensive, + but you don't know in advance what values will be required, so + building a table upfront is wasteful/impossible. + + +

Parameters:

+
    +
  • func + a function of at least one argument +
  • +
+ +

Returns:

+
    + + a function with at least one argument, which is used as the key. +
+ + + + +
+
+ + add_function_factory (mt, fun) +
+
+ associate a function factory with a type. + A function factory takes an object of the given type and + returns a function for evaluating it + + +

Parameters:

+
    +
  • mt + tab + metatable +
  • +
  • fun + func + a callable that returns a function +
  • +
+ + + + + +
+
+ + string_lambda (lf) +
+
+ an anonymous function as a string. This string is either of the form + '|args| expression' or is a function of one argument, '_' + + +

Parameters:

+
    +
  • lf + function as a string +
  • +
+ +

Returns:

+
    + + a function +
+ + + +

Usage:

+
    +
    string_lambda '|x|x+1' (2) == 3
    +string_lambda '_+1' (2) == 3
    +
+ +
+
+ + bind1 (fn, p) +
+
+ bind the first argument of the function to a value. + + +

Parameters:

+
    +
  • fn + a function of at least two values (may be an operator string) +
  • +
  • p + a value +
  • +
+ +

Returns:

+
    + + a function such that f(x) is fn(p,x) +
+ +

Raises:

+ same as function_arg + +

See also:

+ + +

Usage:

+
    +
    local function f(msg, name)
    +  print(msg .. " " .. name)
    +end
    +
    +local hello = utils.bind1(f, "Hello")
    +
    +print(hello("world"))     --> "Hello world"
    +print(hello("sunshine"))  --> "Hello sunshine"
    +
+ +
+
+ + bind2 (fn, p) +
+
+ bind the second argument of the function to a value. + + +

Parameters:

+
    +
  • fn + a function of at least two values (may be an operator string) +
  • +
  • p + a value +
  • +
+ +

Returns:

+
    + + a function such that f(x) is fn(x,p) +
+ +

Raises:

+ same as function_arg + + +

Usage:

+
    +
    local function f(a, b, c)
    +  print(a .. " " .. b .. " " .. c)
    +end
    +
    +local hello = utils.bind1(f, "world")
    +
    +print(hello("Hello", "!"))  --> "Hello world !"
    +print(hello("Bye", "?"))    --> "Bye world ?"
    +
+ +
+
+

Deprecation

+ +
+
+ + set_deprecation_func (func) +
+
+ Sets a deprecation warning function. + An application can override this function to support proper output of + deprecation warnings. The warnings can be generated from libraries or + functions by calling utils.raise_deprecation. The default function + will write to the 'warn' system (introduced in Lua 5.4, or the compatibility + function from the compat module for earlier versions).

+ +

Note: only applications should set/change this function, libraries should not. + + +

Parameters:

+
    +
  • func + a callback with signature: function(msg, trace) both arguments are strings, the latter being optional. +
  • +
+ + + +

See also:

+ + +

Usage:

+
    +
    -- write to the Nginx logs with OpenResty
    +utils.set_deprecation_func(function(msg, trace)
    +  ngx.log(ngx.WARN, msg, (trace and (" " .. trace) or nil))
    +end)
    +
    +-- disable deprecation warnings
    +utils.set_deprecation_func()
    +
+ +
+
+ + raise_deprecation (opts) +
+
+ raises a deprecation warning. + For options see the usage example below.

+ +

Note: the opts.deprecated_after field is the last version in which + a feature or option was NOT YET deprecated! Because when writing the code it + is quite often not known in what version the code will land. But the last + released version is usually known. + + +

Parameters:

+
    +
  • opts + options table +
  • +
+ + + +

See also:

+ + +

Usage:

+
    +
    warn("@on")   -- enable Lua warnings, they are usually off by default
    +
    +function stringx.islower(str)
    +  raise_deprecation {
    +    source = "Penlight " .. utils._VERSION,                   -- optional
    +    message = "function 'islower' was renamed to 'is_lower'", -- required
    +    version_removed = "2.0.0",                                -- optional
    +    deprecated_after = "1.2.3",                               -- optional
    +    no_trace = true,                                          -- optional
    +  }
    +  return stringx.is_lower(str)
    +end
    +-- output: "[Penlight 1.9.2] function 'islower' was renamed to 'is_lower' (deprecated after 1.2.3, scheduled for removal in 2.0.0)"
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + diff --git a/Data/Libraries/Penlight/docs/libraries/pl.xml.html b/Data/Libraries/Penlight/docs/libraries/pl.xml.html new file mode 100644 index 0000000..fb280ab --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.xml.html @@ -0,0 +1,835 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.xml

+

XML LOM Utilities.

+

This implements some useful things on LOM documents, such as returned by lxp.lom.parse. + In particular, it can convert LOM back into XML text, with optional pretty-printing control. + It is s based on stanza.lua from Prosody

+ + +
+> d = xml.parse "<nodes><node id='1'>alice</node></nodes>"
+> = d
+<nodes><node id='1'>alice</node></nodes>
+> = xml.tostring(d,'','  ')
+<nodes>
+   <node id='1'>alice</node>
+</nodes>
+
+ +

Can be used as a lightweight one-stop-shop for simple XML processing; a simple XML parser is included + but the default is to use lxp.lom if it can be found. +

+ Prosody IM
+ Copyright (C) 2008-2010 Matthew Wild
+ Copyright (C) 2008-2010 Waqas Hussain--
+ classic Lua XML parser by Roberto Ierusalimschy.
+ modified to output LOM format.
+ http://lua-users.org/wiki/LuaXml
+ 
+ See the Guide

+ +

Dependencies: pl.utils

+ +

Soft Dependencies: lxp.lom (fallback is to use basic Lua parser)

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
new (tag, attr)create a new document node.
parse (text_or_file, is_file, use_basic)parse an XML document.
Doc:addtag (tag, attrs)convenient function to add a document node, This updates the last inserted position.
Doc:text (text)convenient function to add a text node.
Doc:up ()go up one level in a document
Doc:add_direct_child (child)append a child to a document directly.
Doc:add_child (child)append a child to a document at the last element added
Doc:set_attribs (t)set attributes of a document node.
Doc:set_attrib (a, v)set a single attribute of a document node.
Doc:get_attribs ()access the attributes of a document node.
elem (tag, items)function to create an element with a given tag name and a set of children.
tags (list)given a list of names, return a number of element constructors.
Doc.subst (templ, data)create a substituted copy of a document,
Doc:child_with_name (tag)get the first child with a given tag name.
Doc:get_elements_with_name (tag, dont_recurse)get all elements in a document that have a given tag.
Doc:childtags ()iterate over all child elements of a document node.
Doc:maptags (callback)visit child element of a node and call a function, possibility modifying the document.
tostring (t, idn, indent, attr_indent, xml)pretty-print an XML document
Doc:get_text ()get the full text value of an element
clone (doc, strsubst)make a copy of a document
compare (t1, t2)compare two documents.
is_tag (d)is this value a document element?
walk (doc, depth_first, operation)call the desired function recursively over the document.
parsehtml (s)Parse a well-formed HTML file as a string.
basic_parse (s, all_text, html)Parse a simple XML document using a pure Lua parser based on Robero Ierusalimschy's original version.
+ +
+
+ + +

Functions

+ +
+
+ + new (tag, attr) +
+
+ create a new document node. + + +

Parameters:

+
    +
  • tag + the tag name +
  • +
  • attr + optional attributes (table of name-value pairs) +
  • +
+ + + + + +
+
+ + parse (text_or_file, is_file, use_basic) +
+
+ parse an XML document. By default, this uses lxp.lom.parse, but + falls back to basicparse, or if usebasic is true + + +

Parameters:

+
    +
  • text_or_file + file or string representation +
  • +
  • is_file + whether textorfile is a file name or not +
  • +
  • use_basic + do a basic parse +
  • +
+ +

Returns:

+
    +
  1. + a parsed LOM document with the document metatatables set
  2. +
  3. + nil, error the error can either be a file error or a parse error
  4. +
+ + + + +
+
+ + Doc:addtag (tag, attrs) +
+
+ convenient function to add a document node, This updates the last inserted position. + + +

Parameters:

+
    +
  • tag + a tag name +
  • +
  • attrs + optional set of attributes (name-string pairs) +
  • +
+ + + + + +
+
+ + Doc:text (text) +
+
+ convenient function to add a text node. This updates the last inserted position. + + +

Parameters:

+
    +
  • text + a string +
  • +
+ + + + + +
+
+ + Doc:up () +
+
+ go up one level in a document + + + + + + + +
+
+ + Doc:add_direct_child (child) +
+
+ append a child to a document directly. + + +

Parameters:

+
    +
  • child + a child node (either text or a document) +
  • +
+ + + + + +
+
+ + Doc:add_child (child) +
+
+ append a child to a document at the last element added + + +

Parameters:

+
    +
  • child + a child node (either text or a document) +
  • +
+ + + + + +
+
+ + Doc:set_attribs (t) +
+
+ set attributes of a document node. + + +

Parameters:

+
    +
  • t + a table containing attribute/value pairs +
  • +
+ + + + + +
+
+ + Doc:set_attrib (a, v) +
+
+ set a single attribute of a document node. + + +

Parameters:

+
    +
  • a + attribute +
  • +
  • v + its value +
  • +
+ + + + + +
+
+ + Doc:get_attribs () +
+
+ access the attributes of a document node. + + + + + + + +
+
+ + elem (tag, items) +
+
+ function to create an element with a given tag name and a set of children. + + +

Parameters:

+
    +
  • tag + a tag name +
  • +
  • items + either text or a table where the hash part is the attributes and the list part is the children. +
  • +
+ + + + + +
+
+ + tags (list) +
+
+ given a list of names, return a number of element constructors. + + +

Parameters:

+
    +
  • list + a list of names, or a comma-separated string. +
  • +
+ + + + +

Usage:

+
    +
    local parent,children = doc.tags 'parent,children' <br>
    +  doc = parent {child 'one', child 'two'}
    +
+ +
+
+ + Doc.subst (templ, data) +
+
+ create a substituted copy of a document, + + +

Parameters:

+
    +
  • templ + may be a document or a string representation which will be parsed and cached +
  • +
  • data + a table of name-value pairs or a list of such tables +
  • +
+ +

Returns:

+
    + + an XML document +
+ + + + +
+
+ + Doc:child_with_name (tag) +
+
+ get the first child with a given tag name. + + +

Parameters:

+
    +
  • tag + the tag name +
  • +
+ + + + + +
+
+ + Doc:get_elements_with_name (tag, dont_recurse) +
+
+ get all elements in a document that have a given tag. + + +

Parameters:

+
    +
  • tag + a tag name +
  • +
  • dont_recurse + optionally only return the immediate children with this tag name +
  • +
+ +

Returns:

+
    + + a list of elements +
+ + + + +
+
+ + Doc:childtags () +
+
+ iterate over all child elements of a document node. + + + + + + + +
+
+ + Doc:maptags (callback) +
+
+ visit child element of a node and call a function, possibility modifying the document. + + +

Parameters:

+
    +
  • callback + a function passed the node (text or element). If it returns nil, that node will be removed. + If it returns a value, that will replace the current node. +
  • +
+ + + + + +
+
+ + tostring (t, idn, indent, attr_indent, xml) +
+
+ pretty-print an XML document + + +

Parameters:

+
    +
  • t + an XML document +
  • +
  • idn + an initial indent (indents are all strings) +
  • +
  • indent + an indent for each level +
  • +
  • attr_indent + if given, indent each attribute pair and put on a separate line +
  • +
  • xml + force prefacing with default or custom +
  • +
+ +

Returns:

+
    + + a string representation +
+ + + + +
+
+ + Doc:get_text () +
+
+ get the full text value of an element + + + + + + + +
+
+ + clone (doc, strsubst) +
+
+ make a copy of a document + + +

Parameters:

+
    +
  • doc + the original document +
  • +
  • strsubst + an optional function for handling string copying which could do substitution, etc. +
  • +
+ + + + + +
+
+ + compare (t1, t2) +
+
+ compare two documents. + + +

Parameters:

+
    +
  • t1 + any value +
  • +
  • t2 + any value +
  • +
+ + + + + +
+
+ + is_tag (d) +
+
+ is this value a document element? + + +

Parameters:

+
    +
  • d + any value +
  • +
+ + + + + +
+
+ + walk (doc, depth_first, operation) +
+
+ call the desired function recursively over the document. + + +

Parameters:

+
    +
  • doc + the document +
  • +
  • depth_first + visit child notes first, then the current node +
  • +
  • operation + a function which will receive the current tag name and current node. +
  • +
+ + + + + +
+
+ + parsehtml (s) +
+
+ Parse a well-formed HTML file as a string. + Tags are case-insenstive, DOCTYPE is ignored, and empty elements can be .. empty. + + +

Parameters:

+
    +
  • s + the HTML +
  • +
+ + + + + +
+
+ + basic_parse (s, all_text, html) +
+
+ Parse a simple XML document using a pure Lua parser based on Robero Ierusalimschy's original version. + + +

Parameters:

+
    +
  • s + the XML document to be parsed. +
  • +
  • all_text + if true, preserves all whitespace. Otherwise only text containing non-whitespace is included. +
  • +
  • html + if true, uses relaxed HTML rules for parsing +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0