Class ReduceFunction

java.lang.Object
com.api.jsonata4java.expressions.functions.FunctionBase
com.api.jsonata4java.expressions.functions.ReduceFunction

public class ReduceFunction extends FunctionBase
From http://docs.jsonata.org/higher-order-functions#reduce Signature: $reduce(array, function [, init]) Returns an aggregated value derived from applying the function parameter successively to each value in array in combination with the result of the previous application of the function. The function must accept at least two arguments, and behaves like an infix operator between each value within the array. The signature of this supplied function must be of the form: myfunc($accumulator, $value[, $index[, $array]]) Example ( $product := function($i, $j){$i * $j}; $reduce([1..5], $product) ) This multiplies all the values together in the array [1..5] to return 120. If the optional init parameter is supplied, then that value is used as the initial value in the aggregation (fold) process. If not supplied, the initial value is the first value in the array parameter.
  • Field Details

    • ERR_BAD_CONTEXT

      public static String ERR_BAD_CONTEXT
    • ERR_ARG1BADTYPE

      public static String ERR_ARG1BADTYPE
    • ERR_ARG2BADTYPE

      public static String ERR_ARG2BADTYPE
    • ERR_ARG1_MUST_BE_ARRAY_OF_OBJECTS

      public static String ERR_ARG1_MUST_BE_ARRAY_OF_OBJECTS
  • Constructor Details

    • ReduceFunction

      public ReduceFunction()
  • Method Details