executeFunction

Executes a function.

@safe
Return
executeFunction
(
Return
Mtypes...
)
(
in dstring func
,
in Tuple!(Mtypes) args
,
ulong precision = 18L
)

Parameters

func dstring

The function to execute.

args Tuple!(Mtypes)

The function arguments, expressed as a tuple.

precision ulong

The precision of the returned Mtype.

Return Value

Type: Return

The result of calling the function.

Examples

Tuple!(Number, Number, Number) a;
a[0] = new Number(NumberContainer(BigInt(2), BigInt(0), 0L, 18UL));
a[1] = new Number(NumberContainer(BigInt(3), BigInt(0), 0L, 18UL));
a[2] = new Number(NumberContainer(BigInt(1), BigInt(0), 0L, 18UL));
dstring func = "(Number,Number,Number)(Number)"d;
dstring def = "x1*x2*x3"d;
auto r = registerFunction("ree"d, func, def);
assert(r);
auto i = executeFunction!(Number, Number, Number, Number)("ree(Number,Number,Number)(Number)"d, a);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);
assert(removeFunction("ree"d, func));
def = "(x1*x2)*x3"d;
assert(registerFunction("ree"d, func, def));
i = executeFunction!(Number, Number, Number, Number)("ree(Number,Number,Number)(Number)"d, a);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);
// All of the above is working
def = "x1*(x2*x3)"d;
assert(removeFunction("ree"d, func));
assert(registerFunction("ree"d, func, def));
i = executeFunction!(Number, Number, Number, Number)("ree(Number,Number,Number)(Number)"d, a);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);
def = "(x1*x2)*x3*x4"d;
assert(removeFunction("ree"d, func));
func = "(Number,Number,Number,Number)(Number)"d;
assert(registerFunction("ree"d, func, def));
Tuple!(Number, Number, Number, Number) b;
b[0] = new Number(NumberContainer(BigInt(2), BigInt(0), 0L, 18UL));
b[1] = new Number(NumberContainer(BigInt(3), BigInt(0), 0L, 18UL));
b[2] = new Number(NumberContainer(BigInt(1), BigInt(0), 0L, 18UL));
b[3] = new Number(b[2].val);
i = executeFunction!(Number, Number, Number, Number, Number)("ree(Number,Number,Number,Number)(Number)"d, b);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);
def = "x1*x2*(x3*x4)"d;
assert(removeFunction("ree"d, func));
assert(registerFunction("ree"d, func, def));
i = executeFunction!(Number, Number, Number, Number, Number)("ree(Number,Number,Number,Number)(Number)"d, b);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);
def = "x1*(x2)*x3*(x4)"d;
assert(removeFunction("ree"d, func));
assert(registerFunction("ree"d, func, def));
i = executeFunction!(Number, Number, Number, Number, Number)("ree(Number,Number,Number,Number)(Number)"d, b);
assert(i.toDstring == "6+0i", cast(char[])i.toDstring.dup);
assert(removeFunction("ree"d, func));
def = "((x1)*((x2)*(x3)))*x4"d;
assert(registerFunction("ree"d, func, def));
i = executeFunction!(Number, Number, Number, Number, Number)("ree(Number,Number,Number,Number)(Number)"d, b);
assert(i.toDstring == "6+0i"d, cast(char[])i.toDstring.dup);

Meta