Back to functions



Registers a module function with nerdamer. The object needs to contain at a minimum, a name property (text), a numargs property (int), this is -1 for variable arguments or an array containing the min and max arguments, the visible property (bool) which allows use of this function through nerdamer, defaults to true, and a build property containing a function which returns the function to be used. This function is also handy for creating aliases to functions. See below how the alias D was created for the diff function).

Usage: nerdamer.register(o)


Object | Object[] o An array of objects to be registered

var core = nerdamer.getCore();
var _ = core.PARSER;
function f(a, b) {
//use clone for safety since a or b might be returned
var sum = _.add(a.clone(), b.clone());
var product = _.multiply(a.clone(), b.clone());
return _.multiply(sum, product);
//register the function with nerdamer
   name: 'myFunction',
   numargs: 2,
   visible: true,
   build: function(){ return f; }

//create an alias for the diff function
var core = nerdamer.getCore();
    name: 'D',
    visible: true,
    numargs: [1, 3],
    build: function(){ return core.Calculus.diff; }

var x = nerdamer('D(cos(x),x)');
Back to functions