add contract to 'table'

This commit is contained in:
Robby Findler 2014-10-11 22:35:41 -05:00
parent ec4542383c
commit 735881831b
3 changed files with 13 additions and 5 deletions

View File

@ -674,8 +674,8 @@ Like @racket[pin-over], but @racket[pict] is drawn before
@defproc[(table [ncols exact-positive-integer?] @defproc[(table [ncols exact-positive-integer?]
[picts (non-empty-listof pict?)] [picts (non-empty-listof pict?)]
[col-aligns (list*of (pict? pict? -> pict?))] [col-aligns (list*of (->* () #:rest (listof pict?) pict?))]
[row-aligns (list*of (pict? pict? -> pict?))] [row-aligns (list*of (->* () #:rest (listof pict?) pict?))]
[col-seps (list*of real?)] [col-seps (list*of real?)]
[row-seps (list*of real?)]) [row-seps (list*of real?)])
pict?]{ pict?]{

View File

@ -23,8 +23,18 @@
htl-append htl-append
hbl-append hbl-append
cellophane cellophane
dc) dc
table)
(contract-out (contract-out
[table (->i ([ncols exact-positive-integer?]
[picts (non-empty-listof pict?)]
[col-aligns (list*of (->* () #:rest (listof pict?) pict?))]
[row-aligns (list*of (->* () #:rest (listof pict?) pict?))]
[col-seps (list*of real?)]
[row-seps (list*of real?)])
#:pre (ncols picts)
(zero? (remainder (length picts) ncols))
[result pict?])]
[dc (->i ([draw (-> (is-a?/c dc<%>) real? real? any)] [dc (->i ([draw (-> (is-a?/c dc<%>) real? real? any)]
[w real?] [w real?]
[h real?]) [h real?])

View File

@ -875,8 +875,6 @@
(define table (define table
(case-lambda (case-lambda
[(ncol cells col-aligns row-aligns col-seps row-seps) [(ncol cells col-aligns row-aligns col-seps row-seps)
(unless (positive? ncol)
(raise-type-error 'table "positive column count" ncol))
(let ([count (length cells)]) (let ([count (length cells)])
(unless (zero? (remainder count ncol)) (unless (zero? (remainder count ncol))
(error 'table "cell count isn't divisble by the provided column count")) (error 'table "cell count isn't divisble by the provided column count"))