Export `posn' contract to the HtDP teaching languages.

This commit is contained in:
Mike Sperber 2010-06-09 13:46:51 +02:00
parent 744b45f470
commit f29b6483f9
2 changed files with 7 additions and 1 deletions

View File

@ -1,10 +1,15 @@
#lang racket/base
(require lang/private/contracts/contract-syntax)
;; The posn struct for the teaching languages
(provide (struct-out posn) make-posn)
(provide make-posn posn? posn-x posn-y set-posn-x! set-posn-y!
(rename-out (posn-contract posn)))
(struct posn (x y) #:mutable #:transparent)
;; We define a separate function so tha it has the
;; name `make-posn':
(define (make-posn x y) (posn x y))
(define posn-contract (contract (predicate posn?)))

View File

@ -313,6 +313,7 @@
" in a list of pairs"))
("Posns"
(posn contract "contract for posns")
(make-posn (number number -> posn) "to construct a posn")
(posn? (anything -> boolean) "to determine if its input is a posn")
(posn-x (posn -> number) "to extract the x component of a posn")