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 objectk
: the key
- eq (a, b)
-
returns true if arguments are equal ==
Parameters:
a
: valueb
: value
- neq (a, b)
-
returns true if arguments are not equal ~=
Parameters:
a
: valueb
: value
- lt (a, b)
-
returns true if a is less than b <
Parameters:
a
: valueb
: value
- le (a, b)
-
returns true if a is less or equal to b <=
Parameters:
a
: valueb
: value
- gt (a, b)
-
returns true if a is greater than b >
Parameters:
a
: valueb
: value
- ge (a, b)
-
returns true if a is greater or equal to b >=
Parameters:
a
: valueb
: value
- len (a)
-
returns length of string or table #
Parameters:
a
: a string or a table
- add (a, b)
-
add two values +
Parameters:
a
: valueb
: value
- sub (a, b)
-
subtract b from a -
Parameters:
a
: valueb
: value
- mul (a, b)
-
multiply two values *
Parameters:
a
: valueb
: value
- div (a, b)
-
divide first value by second /
Parameters:
a
: valueb
: value
- pow (a, b)
-
raise first to the power of second ^
Parameters:
a
: valueb
: value
- mod (a, b)
-
modulo; remainder of a divided by b %
Parameters:
a
: valueb
: value
- concat (a, a, b)
-
concatenate two values (either strings or __concat defined) ..
Parameters:
a
: valuea
: valueb
:
- unm (a, a)
-
return the negative of a value -
Parameters:
a
: valuea
: 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
: valuea
: valueb
:
- lor (a, a, b)
-
true if either value evaluate as true (i.e.
not nil or false) or
Parameters:
a
: valuea
: valueb
:
- table (...)
-
make a table from the arguments.
{}
Parameters:
...
: non-nil arguments
Returns:
-
a table
- nop (...)
-
the null operation.
Parameters:
...
: arguments
Returns:
-
the arguments