ExDatalog.Constraints.Arithmetic (ExDatalog v0.2.0)

Copy Markdown View Source

Arithmetic constraint implementation for the Constraint behaviour.

Evaluates arithmetic constraints (:add, :sub, :mul, :div) which bind a result variable. All arithmetic is integer-only. Division by zero filters the binding.

This module is the canonical evaluator for arithmetic operations. It is dispatched to by ExDatalog.Constraint.evaluate/3 when the constraint's op is :add, :sub, :mul, or :div.

Summary

Functions

Evaluates an arithmetic constraint against a binding environment.

Functions

evaluate(constraint, binding, context)

Evaluates an arithmetic constraint against a binding environment.

Accepts an IR.Constraint struct as produced by the compiler. Returns {:ok, extended_binding} when the arithmetic succeeds (result variable is bound), or :filter when division by zero occurs or an input variable is unbound.