Class StreamMap

All Implemented Interfaces:
JepComponent, PostfixMathCommandI, Serializable

public class StreamMap extends BinaryFunction implements JepComponent
Apply a lambda function to a list of arguments returning a list. For example
[1,2,3,4,5] . map(x=>x^2)

If each element in the list is itself a list, a unary lambda function could be use referring to individual items of the list as v[1], v[2] etc.

[[1,1], [2,2], [2,3], [3,2]] . map( v=>v[1]^v[2])
Alternatively lambda functions with multiple parameters on the left hand side could be used as well, each parameter referring to an item in the list, e.g.
[[1,1], [2,2], [2,3], [3,2]] . map( [[a,b]]=>a^b)
See Also:
  • Constructor Details

    • StreamMap

      public StreamMap()
  • Method Details

    • eval

      public Object eval(Object l, Object r) throws EvaluationException
      Description copied from class: BinaryFunction
      Evaluate the function
      Specified by:
      eval in class BinaryFunction
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the results
      Throws:
      EvaluationException - if the function cannot be evaluated.
    • init

      public void init(Jep jep)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Parameters:
      jep - the current Jep instance
    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Description copied from interface: JepComponent
      Gets a light-weight instance suitable for using in multiple threads.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Returns:
      either a new instance, null or 'this'.