Export `posn' contract to the HtDP teaching languages.
This commit is contained in:
parent
744b45f470
commit
f29b6483f9
|
@ -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?)))
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user