Guard drag-ok? so it handles the empty list properly

change suggested by Stefan Schmiedl; closes PR 14164

It seems a bit strange that a region callback can
be invoked when there are no cards, but looking at
the card library it isn't obvious that the list
is supposed to be non-empty, so probably better
to just be "defensive" in this case, rather than
attempting to tighten the contracts
This commit is contained in:
Robby Findler 2013-11-17 16:32:04 -06:00
parent fac70aa121
commit 4db57816fc

View File

@ -195,12 +195,13 @@
#f))) #f)))
(define (drag-ok? cards i) (define (drag-ok? cards i)
(let ([c (car cards)] (and (pair? cards)
[l (vector-ref stacks i)]) (let ([c (car cards)]
(and l [l (vector-ref stacks i)])
(or (null? l) (and l
(= (send (car l) get-value) (or (null? l)
(add1 (send c get-value))))))) (= (send (car l) get-value)
(add1 (send c get-value))))))))
(let loop ([i 0]) (let loop ([i 0])
(unless (= i (vector-length stacks)) (unless (= i (vector-length stacks))