predicator v0.2.0 Predicator.Evaluator

Link to this section Summary

Functions

execute/2 takes an instruction set and context struct

Link to this section Functions

Link to this function execute(inst, context_struct \\ %{})
execute(list, struct | map) ::
  boolean |
  {:error, Predicator.InstructionError.t | Predicator.ValueError.t}

execute/2 takes an instruction set and context struct

Example instructions sets:

iex> execute([[“lit”, true]]) true

iex> Predicator.Evaluator.execute([[“load”, “age”], [“lit”, 18], [“compare”, “GT”]], %{age: 19}) true

iex> Predicator.Evaluator.execute([[“load”, “name”], [“lit”, “jrichocean”], [“compare”, “EQ”]], %{age: 19}) {:error, %Predicator.ValueError{error: “Non valid load value to evaluate”, instruction_pointer: 0, instructions: [[“load”, “name”], [“lit”, “jrichocean”], [“compare”, “EQ”]], stack: []}}