Jump to navigation

Class: funcObj

Numbas.jme.funcObj

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 null, then options.typecheck is used.

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
Source:

Members

(static) description :String

A description of what the function does

Type:
Source:

(static) fn :function

Javascript function for the body of this function

Type:
Source:

(static) id :Number

Globally unique ID of this function object

Type:
Source:

(static) intype :function

Check the given list of arguments against this function's calling signature.

Type:
Source:

(static) name :String

Name

Type:
Source:

(static) outtype :function|String

The return type of this function. Either a Numbas.jme.token constructor function, or the string '?', meaning unknown type.

Type:
Source:

(static) random :Boolean

Does this function behave randomly?

Type:
Source:

Methods

(static) evaluate(args, scope, signature) → {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
signature Numbas.jme.call_signature
Returns:
Type Description
Numbas.jme.token
Source:

(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
Source: