org.matheclipse.core.generic
Class Functors
- java.lang.Object
-
- org.matheclipse.core.generic.Functors
-
public class Functors extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Function<IExpr,IExpr>append(IAST ast)Return a function which clones the given AST and appends the argument to the cloned AST in theapply()method.static Function<IExpr,IExpr>apply(IExpr expr)Return a function which clones the argument, if it is of type AST and sets the header to the givenexpr.static Function<IExpr,IExpr>collect(java.util.Collection<? super IExpr> resultCollection)static Function<IExpr,IExpr>constant(IExpr expr)Return a function which returns the given expression in theapply()method.static Function<IExpr,IExpr>evalArg(IAST ast, int position, EvalEngine engine)Create a functor which evaluates the givenastas a function with the argument at the givenpositionreplaced in theapply()method.static Function<IExpr,IExpr>replace1st(IAST ast)Create a functor, which replaces the argument at the first position in theastwith the argument of the functorsapply()method.static Function<IExpr,IExpr>replace2nd(IAST ast)Create a functor, which replaces the argument at the second position in theastwith the argument of the functorsapply()method.static Function<IExpr,IExpr>replaceAll(IAST ast, IExpr lhs)Create a functor, which replaces all (sub-)expressions inastwhich equalslhswith the argument of the functorsapply()method.static Function<IExpr,IExpr>replaceArg(IAST ast, int position)Create a functor, which replaces the argument at the given position in theastwith the argument of the functorsapply()method.static Function<IExpr,IExpr>rules(IAST astRules)Create a functor from the given rules.static Function<IExpr,IExpr>rules(java.util.Map<? extends IExpr,? extends IExpr> rulesMap)Create a functor from the given map, which calls therulesMap.get()in the functorsapplymethod.static Function<IExpr,IExpr>rules(java.lang.String[] strRules)Create a functor from the given rules.static Function<IExpr,IExpr>scan(IAST ast, java.util.Collection<? super IExpr> resultCollection)Return a function which clones the given AST and appends the argument to the cloned AST in theapply()method.
-
-
-
Method Detail
-
scan
public static Function<IExpr,IExpr> scan(@Nonnull IAST ast, @Nonnull java.util.Collection<? super IExpr> resultCollection)
Return a function which clones the given AST and appends the argument to the cloned AST in theapply()method. The clone is then appended to the result collection.- Parameters:
ast- the AST which should be cloned and appended to in theapplymethodresultCollection- the collection to which the cloned AST will be appended- Returns:
-
append
public static Function<IExpr,IExpr> append(@Nonnull IAST ast)
Return a function which clones the given AST and appends the argument to the cloned AST in theapply()method.- Parameters:
ast- the AST which should be cloned in theapplymethod- Returns:
-
evalArg
public static Function<IExpr,IExpr> evalArg(@Nonnull IAST ast, int position, @Nonnull EvalEngine engine)
Create a functor which evaluates the givenastas a function with the argument at the givenpositionreplaced in theapply()method.- Parameters:
ast- the function which should be evaluatedposition- the position at which the argument should be replacedengine- the current evaluation engine- Returns:
-
apply
public static Function<IExpr,IExpr> apply(@Nonnull IExpr expr)
Return a function which clones the argument, if it is of type AST and sets the header to the givenexpr.expris typically a symbol.- Parameters:
expr-- Returns:
-
collect
public static Function<IExpr,IExpr> collect(@Nonnull java.util.Collection<? super IExpr> resultCollection)
-
constant
public static Function<IExpr,IExpr> constant(@Nonnull IExpr expr)
Return a function which returns the given expression in theapply()method.- Parameters:
expr-- Returns:
-
replaceAll
public static Function<IExpr,IExpr> replaceAll(@Nonnull IAST ast, @Nonnull IExpr lhs)
Create a functor, which replaces all (sub-)expressions inastwhich equalslhswith the argument of the functorsapply()method.- Parameters:
ast- an AST which contains thelhsas a placeholder in it's subexpressions.lhs- left-hand-side of aRule(lhs,...)- Returns:
-
replace1st
public static Function<IExpr,IExpr> replace1st(@Nonnull IAST ast)
Create a functor, which replaces the argument at the first position in theastwith the argument of the functorsapply()method.- Parameters:
ast- an AST where the first argument is replaced with the argument of the functorsapply()method.- Returns:
-
replace2nd
public static Function<IExpr,IExpr> replace2nd(@Nonnull IAST ast)
Create a functor, which replaces the argument at the second position in theastwith the argument of the functorsapply()method.- Parameters:
ast- an AST where the second argument is replaced with the argument of the functorsapply()method.- Returns:
-
replaceArg
public static Function<IExpr,IExpr> replaceArg(@Nonnull IAST ast, int position)
Create a functor, which replaces the argument at the given position in theastwith the argument of the functorsapply()method.- Parameters:
ast- an AST where the element at the givenpositionis replaced with the argument of the functorsapply()method.position- the position of the element, which should be replaced in theast.- Returns:
-
rules
public static Function<IExpr,IExpr> rules(java.util.Map<? extends IExpr,? extends IExpr> rulesMap)
Create a functor from the given map, which calls therulesMap.get()in the functorsapplymethod.- Parameters:
rulesMap-- Returns:
-
rules
public static Function<IExpr,IExpr> rules(@Nonnull java.lang.String[] strRules) throws WrongArgumentType
Create a functor from the given rules. All strings instrRulesare parsed in internal rules form.- Parameters:
strRules- array of rules of the form "x->y"- Returns:
- Throws:
WrongArgumentType
-
rules
public static Function<IExpr,IExpr> rules(@Nonnull IAST astRules) throws WrongArgumentType
Create a functor from the given rules. IfastRulesis aList[]object, the elements of the list are taken as the rules of the formRule[lhs, rhs], otherwise theastRulesitself is taken as theRule[lhs, rhs].- Parameters:
astRules-- Returns:
- Throws:
WrongArgumentType
-
-
DMelt 3.0 © DataMelt by jWork.ORG