new funcObj(name, intype, outcons, fn, options)
A JME function. Capable of confirming that it can be evaluated on a given list of arguments, and returning the result of its evaluation on a list of arguments inside a given scope.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
intype |
Array.<(function()|string)> | A list of data type constructors for the function's parameters' types. Use the string '?' to match any type. Or, give the type's name with a '*' in front to match any number of that type. If |
outcons |
function | The constructor for the output value of the function. |
fn |
Numbas.jme.evaluate_fn | JavaScript code which evaluates the function. |
options |
Numbas.jme.funcObj_options |
Members
(static) description :string
A description of what the function does.
Type:
(static) fn :function
Javascript function for the body of this function.
Type:
(static) id :number
Globally unique ID of this function object.
Type:
(static) intype :function
Check the given list of arguments against this function's calling signature.
Type:
(static) outtype :function|string
The return type of this function. Either a Numbas.jme.token constructor function, or the string '?', meaning unknown type.
Type:
(static) random :boolean
Does this function behave randomly?
Type:
Methods
(static) evaluate(args, scope) → {Numbas.jme.token}
Evaluate this function on the given arguments, in the given scope.
Parameters:
Name | Type | Description |
---|---|---|
args |
Array.<Numbas.jme.token> | |
scope |
Numbas.jme.Scope |
Returns:
Type | Description |
---|---|
Numbas.jme.token |
(static) typecheck(variables) → {boolean}
Can this function be called with the given list of arguments?
Parameters:
Name | Type | Description |
---|---|---|
variables |
Array.<Numbas.jme.token> |
Returns:
Type | Description |
---|---|
boolean |