csp v0.1.0 Csp.Constraint protocol

A constraint protocol: allows defining custom constraints that can be used as part of Csp structs.

Provided implementation

A default impelementation is provided. It implements this protocol for tuple of a list of variables (arguments of the constraint), and a function accepting values of those variables (in the same order as they are specified in the first element of the tuple) returning if the constraint is satisifed by those values of the variables.

For example, this is a constraint that asserts that variables :a and :b should not be equal:

{[:a, :b], fn a, b -> a != b end}

Link to this section Summary

Functions

Returns a list of variables - arguments that this constraint uses.

Checks if constraint is satisfied by assignment.

Link to this section Types

Specs

t() :: any()

Link to this section Functions

Link to this function

arguments(constraint)

Specs

arguments(t()) :: [Csp.variable()]

Returns a list of variables - arguments that this constraint uses.

Link to this function

satisfies?(constraint, assignment)

Specs

satisfies?(t(), Csp.assignment()) :: boolean()

Checks if constraint is satisfied by assignment.