Class AssignableList

All Implemented Interfaces:
LValueI, PostfixMathCommandI, Serializable

public class AssignableList extends List implements LValueI
A list than can be assigned to [x,y,z] = [1,2,3]. Items in the left hand side list must be variables or functions implementing LValueI. This allow elements in a vector to be swapped [v[2],v[1]]=v.

This function can be used as a replacement for List


     Jep jep = new Jep(new StandardConfigurableParser());
     jep.getOperatorTable().getList().setPFMC(new AssignableList());
     Node n = jep.parse("[x,y] = [3,4]");
     Object res = jep.evaluate(n);
 
Since:
Jep 4.1
See Also:
  • Constructor Details

    • AssignableList

      public AssignableList()
  • Method Details

    • set

      public void set(Evaluator pv, Node node, Object value) throws EvaluationException
      Description copied from interface: LValueI
      Performs appropriate action to set an LValue.
      Specified by:
      set in interface LValueI
      Parameters:
      pv - a pointer to the evaluator. The pv.eval() method can be used to evaluate the children of the node.
      node - The top node for the LValue
      value - the value obtained by evaluating the right-hand side.
      Throws:
      EvaluationException - if the calculation cannot be performed