From 78cda8254fe927caa758a5ee1569830fef5d3f21 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 2 Oct 2014 23:03:59 -0700 Subject: [PATCH] small change --- csp/constraint.rkt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/csp/constraint.rkt b/csp/constraint.rkt index f8aac606..bc0533a5 100644 --- a/csp/constraint.rkt +++ b/csp/constraint.rkt @@ -40,16 +40,15 @@ ;; Helper method for generic forward checking ;; Currently, this method acts only when there's a single ;; unassigned variable. - (define return-result #t) - - (define unassignedvariable _unassigned) - ;(report assignments) + (define return-result (void)) (let/ec break - (for ([variable (in-list variables)]) - (when (not (variable . in? . assignments)) - (if (equal? unassignedvariable _unassigned) - (set! unassignedvariable variable) - (break)))) + (set! return-result #t) + (define unassignedvariable _unassigned) + (for ([variable (in-list variables)] + #:when (not (hash-has-key? assignments variable))) + (if (equal? unassignedvariable _unassigned) + (set! unassignedvariable variable) + (break))) (when (not (equal? unassignedvariable _unassigned)) ;; Remove from the unassigned variable domain's all ;; values which break our variable's constraints.