Package org.eolang

Class ExprReduce<T>

  • Type Parameters:
    T - Type of arguments
    All Implemented Interfaces:
    Expr

    public final class ExprReduce<T>
    extends Object
    implements Expr
    Builds a phi performing reduction operation on varargs parameter.
    The expression iterates over varargs (including rho) one by one performing provided reduction operation. Type checking is done for each vararg.

    Definition example:

         final VarargExpr<Long> expr = new VarargExpr<>(
             "plus",
             "x",
             Long.class,
             Long::sum,
         );
     
    Since:
    1.0
    • Constructor Detail

      • ExprReduce

        public ExprReduce​(String oper,
                          String param,
                          Class<T> type,
                          BiFunction<T,​T,​T> reduction,
                          Function<T,​String> validation)
        Ctor.
        Parameters:
        oper - Operation name
        param - Name of parameter with varargs
        type - Type of varargs
        reduction - Reduction operation on consecutive varags
        validation - Validation function
      • ExprReduce

        public ExprReduce​(String oper,
                          String param,
                          Class<T> type,
                          BiFunction<T,​T,​T> reduction)
        Ctor.
        Parameters:
        oper - Peration name
        param - Name of parameter with varargs
        type - Type of varargs
        reduction - Reduction operation on consecutive varargs
    • Method Detail

      • get

        public Phi get​(Phi rho)
        Description copied from interface: Expr
        Get the object.
        Specified by:
        get in interface Expr
        Parameters:
        rho - The \rho of this expression (the parent of it)
        Returns:
        The Phi calculated