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

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, a, b) concatenate two values (either strings or __concat defined) ..
unm (a, a) return the negative of a value -
lnot (a) false if value evaluates as true (i.e.
land (a, a, b) true if both values evaluate as true (i.e.
lor (a, a, b) true if either value evaluate as true (i.e.
table (...) make a table from the arguments.
nop (...) the null operation.


Functions

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

Parameters:

  • fn: a function or callable object
  • ...:
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, a, b)
concatenate two values (either strings or __concat defined) ..

Parameters:

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

Parameters:

  • a: value
  • a: value
lnot (a)
false if value evaluates as true (i.e. not nil or false) not

Parameters:

  • a: value
land (a, a, b)
true if both values evaluate as true (i.e. not nil or false) and

Parameters:

  • a: value
  • a: value
  • b:
lor (a, a, b)
true if either value evaluate as true (i.e. not nil or false) or

Parameters:

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

Parameters:

  • ...: non-nil arguments

Returns:

    a table
nop (...)
the null operation.

Parameters:

  • ...: arguments

Returns:

    the arguments