some more errors

main
Matthew Butterick 3 years ago
parent 1f52342a55
commit c0eaa6ac57

@ -101,8 +101,13 @@
((csp? name?) ((or/c (listof any/c) procedure?)) . ->* . void?)
(add-vars! prob (list name) vals-or-procedure))
(define/contract (add-constraints! prob proc namess [proc-name #false])
(define/contract (add-constraints! prob proc namess [proc-name #false]
#:caller [caller-id 'add-constraints!])
((csp? procedure? (listof (listof name?))) ((or/c #false name?)) . ->* . void?)
(unless (procedure? proc)
(raise-argument-error caller-id "procedure" proc))
(unless (and (list? namess) (andmap (λ (ns) (and (list? ns) (andmap name? ns))) namess))
(raise-argument-error caller-id "list of lists of names" namess))
(set-csp-constraints! prob (append (constraints prob)
(for/list ([names (in-list namess)])
(for ([name (in-list names)])
@ -113,15 +118,18 @@
(define/contract (add-pairwise-constraint! prob proc names [proc-name #false])
((csp? procedure? (listof name?)) (name?) . ->* . void?)
(add-constraints! prob proc (combinations names 2) proc-name))
(unless (and (list? names) (andmap name? names))
(raise-argument-error 'add-pairwise-constraint! "list of names" names))
(add-constraints! prob proc (combinations names 2) proc-name #:caller 'add-pairwise-constraint!))
(define/contract (add-constraint! prob proc names [proc-name #false])
((csp? procedure? (listof name?)) (name?) . ->* . void?)
(add-constraints! prob proc (list names) proc-name))
(add-constraints! prob proc (list names) proc-name #:caller 'add-constraint!))
(define/contract (alldiff= x y)
(define/contract (alldiff x y)
(any/c any/c . -> . boolean?)
(not (= x y)))
(define alldiff= alldiff)
(struct backtrack (histories) #:transparent)
(define (backtrack! [names null]) (raise (backtrack names)))

@ -254,6 +254,8 @@ void?]
void?]
)]{
Imperatively add a new constraint. The constraint applies the function @racket[_func] to the list of variable names given in @racket[_names]. The return value of @racket[_func] does not need to be a Boolean, but any return value other than @racket[#false] is treated as if it were @racket[#true].
@racket[add-constraints!] is the same, but adds the constraint @racket[_func] to each list of variable names in @racket[_namess] (which is therefore a list of lists of variable names).
}
@defproc[(add-pairwise-constraint!

Loading…
Cancel
Save