# Package net.sf.saxon.functions.hof

The package `com.saxonica.hof` contains code to support higher-order functions.

Higher-order functions are supported in XSLT 3.0, XPath 3.1, and XQuery 3.1, in Saxon-PE and Saxon-EE only.

The package includes code to support both the core facilities of dynamic creation and invocation of function objects, and also specific higher-order functions defined in the Functions and Operators library such as `fn:filter`, `fn:for-each` and `fn:fold-left`.

- Class Summary
  Class | Description
  --- | ---
  AtomicConstructorFunction | A function item representing a constructor function for an atomic type
  CallableWithBoundFocus | A Callable that wraps another Callable and a Dynamic Context, in effect acting as a closure that executes the original callable with a saved context.
  CoercedFunction | A function item obtained by coercing a supplied function; this adds a wrapper to perform dynamic type checking of the arguments in any call, and type checking of the result.
  CurriedFunction | A function obtained by currying another function, that is, the result of calling fn:partial-apply
  FilterFn | This class implements the function fn:filter(), which is a standard function in XQuery 3.0
  FoldLeftFn | This class implements the function fn:fold-left(), which is a standard function in XPath 3.0
  FoldRightFn | This class implements the function fn:fold-right(), which is a standard function in XQuery 1.1
  ForEachFn | This class implements the function fn:for-each() (formerly fn:map), which is a standard function in XQuery 3.0
  ForEachPairFn | This class implements the function fn:for-each-pair() (formerly fn:map-pairs()), which is a standard function in XQuery 3.0
  FunctionArity | This class implements the function function-arity(), which is a standard function in XPath 3.0
  FunctionLiteral | A FunctionLiteral is a wrapper around a FunctionItem; it is an expression, whose value is the function that it wraps.
  FunctionLookup | This class supports the function-lookup() function in XPath 3.0.
  FunctionName | This class implements the function function-name(), which is a standard function in XPath 3.0
  FunctionSequenceCoercer | An FunctionSequenceCoercer is an expression that performs function coercion on a sequence of function items: it takes a sequence of supplied items as input, and wraps each one in a CoercedFunction value, which dynamically converts the supplied arguments to the required type, and converts the result in the opposite direction, or throws a type error if conversion is not possible.
  FunctionSequenceCoercer.Coercer |
  LoadXqueryModule | This class implements the function load-xquery-module(), which is a standard function in XPath 3.1.
  PartialApply | This expression class implements the operation of currying (or performing partial application) of a function.
  RandomNumberGenerator | This class implements the function random-number-generator(), which is a standard function in XPath 3.1
  Sort_3 | This class implements the function fn:sort#2, which is a higher-order function in XPath 3.1 available only in Saxon-PE and above
  SystemFunctionWithBoundContextItem | A Callable that wraps another Callable and a Dynamic Context, in effect acting as a closure that executes the original callable with a saved context.
  UnresolvedXQueryFunctionItem |
  UserFunctionReference | A UserFunctionReference is an expression in the form local:f#1 where local:f is a user-defined function.
  UserFunctionReference.BoundUserFunction | A BoundUserFunction represents a user-defined function seen as a component.