[racket] are these right structs and contracts

From: Roelof Wobben (r.wobben at home.nl)
Date: Mon Jul 2 12:39:02 EDT 2012

Hello,

Im now trying to design exercise 88 and I wonder if these are good 
designed structs.

(define-struct Vcat (X H R))
; Vcat = (make-Vcat Number Number String)
; interp. (make-cat x h) where x is the x-coordinate of the cat and h is 
the happiness of the cat and r is the direction of the cat
; make-editor Number Number String -> Vcat
; Vcat-X Vcat Vcat-> Number
; Vcat-Ht Vcat Vcat-> Number
; Vcat-R  Vcat-> String
; Vcat? Any -> Boolean


(define-struct Vcham (X H R))
; Vcham = (make-Vchan Number Number String)
; interp. (make-editor x h r) where x is the x-coordinate of the cham 
and h is the happiness of the cham abnd r is the direction of the cham.
; make-editor Number Number String -> Vcham
; Vcham-Xcham Vcham -> Number
; Vcham-Hcham  Vcham -> Number
; Vcham-Richting  Vchan-> String
; Vcham?  Any -> Boolean

(define-struct VZoo (Vcat Vcham))
; Zoo - (make-Vzoo struct struct)
; interp. (make-Vzoo Vcat Vcham) where Vcat and Vcham are both structs 
containing the parameters of that particular struct.
; make-Vzoo Vcat Vcham -> Vzoo
; Vzoo-Vcat Vzoo -> Vcat
; Vzoo-Vcham Vzoo -> Vcham
; Vzoo? any -> Boolean

And if I want to know the happiness of a Vcat must I use (Vcham-H Vcham) 
or do i have to use Vzoo( Vcat (Vcham-H Vcham)
As I understand it right Vcat is now a part of Vzoo.

Roelof


Posted on the users mailing list.