
xdmp.function( function as xs.QName?, [module-path as String?] ) as function
  Returns a function value as an  
  xdmp.function type. 
  You can return an  
  xdmp.function from an expression or
  a function.  You can execute the function referred to by an
   
  xdmp.function
  by passing the  
   xdmp.function value to
  xdmp.apply. If the module-path ends with a file 
  extension matching the ones configured for 
  application/vnd.marklogic-javascript in your
  MarkLogic Mimetypes configuration, and the function's namespace URI is
  empty, the module is considered to be JavaScript.  In this case, the function
  parameter can be empty.
xdmp.function(xs.QName("fn:empty"))
var f = xdmp.function(xs.QName("fn:concat"));
xdmp.apply(f, "hello", " world");
=> hello world
// Given square.sjs in the modules database as the following:
module.exports = function(width) {
  return {
    area: function() {
      return width * width;
    },
    set: function(_width) {
      width = _width;
    }
  };
}
// then you can run the following
var mySquare = fn.head(xdmp.apply(xdmp.function(null,"square.sjs"),4));
xdmp.apply(mySquare.set, 3);
xdmp.apply(mySquare.area)
=> 9