main
Matthew Butterick 10 years ago
parent ca718a9a0f
commit d5fe7ec60c

@ -78,43 +78,23 @@
(let loop2 ()
;; We have a variable. Do we have any values left?
(when (null? values)
;; No. Go back to last variable, if there's one.
(hash-remove! assignments variable)
(if #f
;; No. Go back to last variable, if there's one, else exit.
(for/or ([i (in-naturals)])
(hash-remove! assignments variable)
(when (null? queue) (set! want-to-return #t) (return-k))
(set!-values (variable values pushdomains) (pop-vvp-values! queue))
(for-each-send pop-state pushdomains)
(if (not (null? values))
#t
(hash-remove! assignments variable)))
(let/ec break-loop3
(let loop ()
(when (null? queue)
(set! want-to-return #t)
(return-k))
(set!-values (variable values pushdomains) (pop-vvp-values! queue))
(for-each-send pop-state pushdomains)
(when (not (null? values)) (break-loop3))
(hash-remove! assignments variable)
(loop)))
)
)
(not (null? values))))
;; Got a value. Check it.
(hash-set! assignments variable (car-pop! values))
(for-each-send push-state pushdomains)
(let/ec break-for-loop
(for ([cvpair (in-list (hash-ref vconstraints variable))])
(match-define (list constraint variables) cvpair)
(define the_result (send constraint call variables domains assignments pushdomains))
(when (not the_result) ; Value is not good.
(break-for-loop)))
(break-loop2))
(if (for/or ([cvpair (in-list (hash-ref vconstraints variable))])
(match-define (list constraint variables) cvpair)
(not (send constraint call variables domains assignments pushdomains)))
(break-for-loop)
(break-loop2)))
(for-each-send pop-state pushdomains)
(loop2)))

Loading…
Cancel
Save