- ac-3 cspprocedure
Check arc-consistency of a csp; returns #t if the object is arc-consistent.
- csp
- A constraint-satisfaction object
(define (ac-3 csp) (let ((queue (list->queue (hash-table-keys (csp-constraints csp))))) (let iter () (if (queue-empty? queue) #t (match (queue-remove! queue) ((x . y) (if (revise csp x y) (if (zero? (length (hash-table-ref (csp-domains csp) x))) #f (begin (for-each (lambda (neighbor) (queue-add! queue (cons neighbor x))) (delete y (hash-table-ref (csp-neighbors csp) x))) (iter))) (iter))))))))