Solid.Expression (solid v0.15.2) View Source

Expression evaluation for the following binary operators: == != > < >= <= Also combine expressions with and, or

Link to this section Summary

Functions

Evaluate a single expression iex> Solid.Expression.eval({"Beer Pack", :contains, "Pack"}) true iex> Solid.Expression.eval({1, :==, 2}) false iex> Solid.Expression.eval({1, :==, 1}) true iex> Solid.Expression.eval({1, :!=, 2}) true iex> Solid.Expression.eval({1, :!=, 1}) false iex> Solid.Expression.eval({1, :<, 2}) true iex> Solid.Expression.eval({1, :<, 1}) false iex> Solid.Expression.eval({1, :>, 2}) false iex> Solid.Expression.eval({2, :>, 1}) true iex> Solid.Expression.eval({1, :>=, 1}) true iex> Solid.Expression.eval({1, :>=, 0}) true iex> Solid.Expression.eval({1, :>=, 2}) false iex> Solid.Expression.eval({1, :<=, 1}) true iex> Solid.Expression.eval({1, :<=, 0}) false iex> Solid.Expression.eval({1, :<=, 2}) true iex> Solid.Expression.eval({"Meat", :contains, "Pack"}) false iex> Solid.Expression.eval({["Beer", "Pack"], :contains, "Pack"}) true iex> Solid.Expression.eval({["Meat"], :contains, "Pack"}) false iex> Solid.Expression.eval({nil, :contains, "Pack"}) false iex> Solid.Expression.eval({"Meat", :contains, nil}) false iex> Solid.Expression.eval(true) true iex> Solid.Expression.eval(false) false iex> Solid.Expression.eval(nil) false iex> Solid.Expression.eval(1) true iex> Solid.Expression.eval("") true iex> Solid.Expression.eval({0, :<=, nil}) false iex> Solid.Expression.eval({1.0, :<, nil}) false iex> Solid.Expression.eval({nil, :>=, 1.0}) false iex> Solid.Expression.eval({nil, :>, 0}) false

Evaluate a list of expressions combined with or, and

Link to this section Types

Specs

value() :: number() | iolist() | boolean() | nil

Link to this section Functions

Specs

eval({value(), atom(), value()} | value()) :: boolean()

Evaluate a single expression iex> Solid.Expression.eval({"Beer Pack", :contains, "Pack"}) true iex> Solid.Expression.eval({1, :==, 2}) false iex> Solid.Expression.eval({1, :==, 1}) true iex> Solid.Expression.eval({1, :!=, 2}) true iex> Solid.Expression.eval({1, :!=, 1}) false iex> Solid.Expression.eval({1, :<, 2}) true iex> Solid.Expression.eval({1, :<, 1}) false iex> Solid.Expression.eval({1, :>, 2}) false iex> Solid.Expression.eval({2, :>, 1}) true iex> Solid.Expression.eval({1, :>=, 1}) true iex> Solid.Expression.eval({1, :>=, 0}) true iex> Solid.Expression.eval({1, :>=, 2}) false iex> Solid.Expression.eval({1, :<=, 1}) true iex> Solid.Expression.eval({1, :<=, 0}) false iex> Solid.Expression.eval({1, :<=, 2}) true iex> Solid.Expression.eval({"Meat", :contains, "Pack"}) false iex> Solid.Expression.eval({["Beer", "Pack"], :contains, "Pack"}) true iex> Solid.Expression.eval({["Meat"], :contains, "Pack"}) false iex> Solid.Expression.eval({nil, :contains, "Pack"}) false iex> Solid.Expression.eval({"Meat", :contains, nil}) false iex> Solid.Expression.eval(true) true iex> Solid.Expression.eval(false) false iex> Solid.Expression.eval(nil) false iex> Solid.Expression.eval(1) true iex> Solid.Expression.eval("") true iex> Solid.Expression.eval({0, :<=, nil}) false iex> Solid.Expression.eval({1.0, :<, nil}) false iex> Solid.Expression.eval({nil, :>=, 1.0}) false iex> Solid.Expression.eval({nil, :>, 0}) false

Link to this function

eval(exps, context, opts \\ [])

View Source

Specs

Evaluate a list of expressions combined with or, and