Postfix.Simple (postfix v1.1.334)

Evaluator of terms using postfix notation

Link to this section Summary

Functions

Evaluate a list of values and functions

Link to this section Functions

@spec eval([term()]) :: {:ok, term()} | {:error, any()}

Evaluate a list of values and functions

iex> Postfix.Simple.eval([2, 3, &*/2, 4, &+/2])
{:ok, 10}

iex> Postfix.Simple.eval([1, 2, &-/2])
{:ok, -1}

Operands are given to the function in the natural left-to-right order. All operands are consumed by the function - the arity is not checked.