Expressions¶
- class Expression¶
A server side expression.
- static constant_double(value)¶
A constant value of double precision floating point type.
- Parameters:
value (float) –
- Return type:
- static constant_float(value)¶
A constant value of single precision floating point type.
- Parameters:
value (float) –
- Return type:
- static constant_int(value)¶
A constant value of integer type.
- Parameters:
value (int) –
- Return type:
- static constant_bool(value)¶
A constant value of boolean type.
- Parameters:
value (bool) –
- Return type:
- static constant_string(value)¶
A constant value of string type.
- Parameters:
value (str) –
- Return type:
- static call(call)¶
An RPC call.
- Parameters:
call (krpc.schema.KRPC.ProcedureCall) –
- Return type:
- static equal(arg0, arg1)¶
Equality comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static not_equal(arg0, arg1)¶
Inequality comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static greater_than(arg0, arg1)¶
Greater than numerical comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static greater_than_or_equal(arg0, arg1)¶
Greater than or equal numerical comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static less_than(arg0, arg1)¶
Less than numerical comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static less_than_or_equal(arg0, arg1)¶
Less than or equal numerical comparison.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static and_(arg0, arg1)¶
Boolean and operator.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static or_(arg0, arg1)¶
Boolean or operator.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static exclusive_or(arg0, arg1)¶
Boolean exclusive-or operator.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static not_(arg)¶
Boolean negation operator.
- Parameters:
arg (Expression) –
- Return type:
- static add(arg0, arg1)¶
Numerical addition.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static subtract(arg0, arg1)¶
Numerical subtraction.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static multiply(arg0, arg1)¶
Numerical multiplication.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static divide(arg0, arg1)¶
Numerical division.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static modulo(arg0, arg1)¶
Numerical modulo operator.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Returns:
The remainder of arg0 divided by arg1
- Return type:
- static power(arg0, arg1)¶
Numerical power operator.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Returns:
arg0 raised to the power of arg1, with type of arg0
- Return type:
- static left_shift(arg0, arg1)¶
Bitwise left shift.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static right_shift(arg0, arg1)¶
Bitwise right shift.
- Parameters:
arg0 (Expression) –
arg1 (Expression) –
- Return type:
- static cast(arg, type)¶
Perform a cast to the given type.
- Parameters:
arg (Expression) –
type (Type) – Type to cast the argument to.
- Return type:
- static parameter(name, type)¶
A named parameter of type double.
- Parameters:
name (str) – The name of the parameter.
type (Type) – The type of the parameter.
- Returns:
A named parameter.
- Return type:
- static function(parameters, body)¶
A function.
- Parameters:
parameters (list) – The parameters of the function.
body (Expression) – The body of the function.
- Returns:
A function.
- Return type:
- static invoke(function, args)¶
A function call.
- Parameters:
function (Expression) – The function to call.
args (dict) – The arguments to call the function with.
- Returns:
A function call.
- Return type:
- static create_tuple(elements)¶
Construct a tuple.
- Parameters:
elements (list) – The elements.
- Returns:
The tuple.
- Return type:
- static create_list(values)¶
Construct a list.
- Parameters:
values (list) – The value. Should all be of the same type.
- Returns:
The list.
- Return type:
- static create_set(values)¶
Construct a set.
- Parameters:
values (set) – The values. Should all be of the same type.
- Returns:
The set.
- Return type:
- static create_dictionary(keys, values)¶
Construct a dictionary, from a list of corresponding keys and values.
- Parameters:
keys (list) – The keys. Should all be of the same type.
values (list) – The values. Should all be of the same type.
- Returns:
The dictionary.
- Return type:
- static to_list(arg)¶
Convert a collection to a list.
- Parameters:
arg (Expression) – The collection.
- Returns:
The collection as a list.
- Return type:
- static to_set(arg)¶
Convert a collection to a set.
- Parameters:
arg (Expression) – The collection.
- Returns:
The collection as a set.
- Return type:
- static get(arg, index)¶
Access an element in a tuple, list or dictionary.
- Parameters:
arg (Expression) – The tuple, list or dictionary.
index (Expression) – The index of the element to access. A zero indexed integer for a tuple or list, or a key for a dictionary.
- Returns:
The element.
- Return type:
- static count(arg)¶
Number of elements in a collection.
- Parameters:
arg (Expression) – The list, set or dictionary.
- Returns:
The number of elements in the collection.
- Return type:
- static sum(arg)¶
Sum all elements of a collection.
- Parameters:
arg (Expression) – The list or set.
- Returns:
The sum of the elements in the collection.
- Return type:
- static max(arg)¶
Maximum of all elements in a collection.
- Parameters:
arg (Expression) – The list or set.
- Returns:
The maximum elements in the collection.
- Return type:
- static min(arg)¶
Minimum of all elements in a collection.
- Parameters:
arg (Expression) – The list or set.
- Returns:
The minimum elements in the collection.
- Return type:
- static average(arg)¶
Minimum of all elements in a collection.
- Parameters:
arg (Expression) – The list or set.
- Returns:
The minimum elements in the collection.
- Return type:
- static select(arg, func)¶
Run a function on every element in the collection.
- Parameters:
arg (Expression) – The list or set.
func (Expression) – The function.
- Returns:
The modified collection.
- Return type:
- static where(arg, func)¶
Run a function on every element in the collection.
- Parameters:
arg (Expression) – The list or set.
func (Expression) – The function.
- Returns:
The modified collection.
- Return type:
- static contains(arg, value)¶
Determine if a collection contains a value.
- Parameters:
arg (Expression) – The collection.
value (Expression) – The value to look for.
- Returns:
Whether the collection contains a value.
- Return type:
- static aggregate(arg, func)¶
Applies an accumulator function over a sequence.
- Parameters:
arg (Expression) – The collection.
func (Expression) – The accumulator function.
- Returns:
The accumulated value.
- Return type:
- static aggregate_with_seed(arg, seed, func)¶
Applies an accumulator function over a sequence, with a given seed.
- Parameters:
arg (Expression) – The collection.
seed (Expression) – The seed value.
func (Expression) – The accumulator function.
- Returns:
The accumulated value.
- Return type:
- static concat(arg1, arg2)¶
Concatenate two sequences.
- Parameters:
arg1 (Expression) – The first sequence.
arg2 (Expression) – The second sequence.
- Returns:
The first sequence followed by the second sequence.
- Return type:
- static order_by(arg, key)¶
Order a collection using a key function.
- Parameters:
arg (Expression) – The collection to order.
key (Expression) – A function that takes a value from the collection and generates a key to sort on.
- Returns:
The ordered collection.
- Return type:
- static all(arg, predicate)¶
Determine whether all items in a collection satisfy a boolean predicate.
- Parameters:
arg (Expression) – The collection.
predicate (Expression) – The predicate function.
- Returns:
Whether all items satisfy the predicate.
- Return type:
- static any(arg, predicate)¶
Determine whether any item in a collection satisfies a boolean predicate.
- Parameters:
arg (Expression) – The collection.
predicate (Expression) – The predicate function.
- Returns:
Whether any item satisfies the predicate.
- Return type: