CPSC 110 Midterm 1 with Complete Solutions
What are the examples for an Enumeration Data Definition? - ANSWER-;;<examples
are redundant for enumerations>
What are the template rules for an atomic non-distinct Data Definition? -
ANSWER-;;Template rules used:
;; -atomic non-distinct
What are the template rules for an Interval Data Definition that includes numbers 1-100?
- ANSWER-;;Template rules used:
;; - atomic non-distinct: Natural[1,100]
What are the template rules used for an Enumeration Data Definition for Names that
include Amelia, Briana, Alma and Charlotte? - ANSWER-;;Template rules used:
;; -one of: 3 cases
;; -atomic distinct value: "Amelia"
;; -atomic distinct value: "Briana"
;; -atomic distinct value: "Alma"
;; -atomic distinct value: "Chelsea"
What are the template rules used for an itemization Data Definition where TrafficLight is
either false, red, yellow or green? - ANSWER-;;Template rules used:
;; -one of: 4 cases
;; -atomic distinct: false
;; -atomic distinct: "red"
;; -atomic distinct: "yellow"
;; -atomic distinct: "green"
What comes after the Interpretation in a Data Definition? - ANSWER-Examples
What comes after the type comment in a Data Definition? - ANSWER-Interpretation
What is the template for an atomic non-distinct data definition for StreetName? -
ANSWER-(define (fn-for-street-name sn)
(... sn))
What is the template for an Enumeration Data Definition for Names that include Amelia,
Briana, Alma and Charlotte? - ANSWER-(define (fn-for-names n)
[(string=? n "Amelia") (...)]
[(string=? n "Briana") (...)]
[(string=? n "Alma") (...)]
[(string=? n "Charlotte") (...)]
What is the template for an itemization Data Definition where TrafficLight is either false,
red, yellow or green? - ANSWER-(define (fn-for-traffic-light tl)
What are the examples for an Enumeration Data Definition? - ANSWER-;;<examples
are redundant for enumerations>
What are the template rules for an atomic non-distinct Data Definition? -
ANSWER-;;Template rules used:
;; -atomic non-distinct
What are the template rules for an Interval Data Definition that includes numbers 1-100?
- ANSWER-;;Template rules used:
;; - atomic non-distinct: Natural[1,100]
What are the template rules used for an Enumeration Data Definition for Names that
include Amelia, Briana, Alma and Charlotte? - ANSWER-;;Template rules used:
;; -one of: 3 cases
;; -atomic distinct value: "Amelia"
;; -atomic distinct value: "Briana"
;; -atomic distinct value: "Alma"
;; -atomic distinct value: "Chelsea"
What are the template rules used for an itemization Data Definition where TrafficLight is
either false, red, yellow or green? - ANSWER-;;Template rules used:
;; -one of: 4 cases
;; -atomic distinct: false
;; -atomic distinct: "red"
;; -atomic distinct: "yellow"
;; -atomic distinct: "green"
What comes after the Interpretation in a Data Definition? - ANSWER-Examples
What comes after the type comment in a Data Definition? - ANSWER-Interpretation
What is the template for an atomic non-distinct data definition for StreetName? -
ANSWER-(define (fn-for-street-name sn)
(... sn))
What is the template for an Enumeration Data Definition for Names that include Amelia,
Briana, Alma and Charlotte? - ANSWER-(define (fn-for-names n)
[(string=? n "Amelia") (...)]
[(string=? n "Briana") (...)]
[(string=? n "Alma") (...)]
[(string=? n "Charlotte") (...)]
What is the template for an itemization Data Definition where TrafficLight is either false,
red, yellow or green? - ANSWER-(define (fn-for-traffic-light tl)