CS计算机代考程序代写 DrRacket ;; The first three lines of this file were inserted by DrRacket. They record metadata

;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib “htdp-beginner-reader.ss” “lang”)((modname hw4) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Problem 3

;; Consider the following data definitions and interpretations.

(define-struct sneaker [is-running])
;; A ShoeKind is one of:
;; – (make-sneakers Boolean)
;; – “dress”
;; – “boots”
;; – “other”
;; Interpretation: Represents some shoe varieties. In (make-sneakers r),
;; r is #true when the sneaker is a running shoe. The “other”
;; variety is used for the many other kinds of shoes that aren’t listed.

(define-struct shoe [brand laced kind])
;; A Shoe is a (make-shoe String Boolean ShoeKind).
;; Interpretation: A (make-shoe b l k) represents a shoe made by b,
;; of kind k, which has laces when l is #true, and is a slip-on shoe
;; when l is #false.

;; Part A

;; Define five distinct examples of Shoe data. Make sure that your
;; examples are representative, and are distinct enough to cover all the
;; interesting differences in this data.

;; [TODO] Five examples

;; Part B

;; Write templates for all data definitions above.

;; [TODO] Templates

;; Part C

;; Consider the following function definitions:

(define (foo u)
(cond
[(sneaker? u)
(if (sneaker-is-running u)
“running shoes”
“sneakers”)]
[(string=? u “dress”) “dress shoes”]
[(string=? u “boots”) “boots”]
[(string=? u “other”) “”]))

(define (bar t)
(string-append (foo (shoe-kind t)) ” by ” (shoe-brand t)))

;; Write the signatures for the functions foo and bar.

;; Hint: The names “foo”, “bar”, “u”, and “t” are not helpful. It may help you
;; to come up with better names as well. However, this is completely optional.
;; If you do so, feel free to change the names in the code above.

;; [TODO] Better signatures for foo and bar