Unformatted text preview: t; 0 x ) true ]
[ ( < x 50 ) true ]
[ else false ] ) ) C: ( define ( cond3 x )
( or ( < x 50 ) ( < 0 x ) ) ) D: ( define ( cond4 x )
( cond [ ( < 0 x ) ( < x 50 ) ) ]
[ else false ] ) ) Circle all pairs that are equivalent:
( A and B ) ( A and C ) ( A and D ) ( B and C ) ( B and D ) ( C and D ) d) [ 4 marks ] Complete the following Scheme predicate, which could be used if check-expect was not
;; check-answer: any any → boolean
;; produces true if actual and expected are equal, and false otherwise
;; example: ( check-answer “ABC” 123 ) → false
;; example: ( check-answer 123 123 ) → true
( define ( check-answer actual expected ) Question 2. [ 10 marks ] Writing a Conditional Function
Complete the function weather-message that produces a string describing the weather, as determined by
a given temperature( according to the table below ) and a string describing current conditions ( e.g.
“snowing”, “sunny”, etc. ). The String produced should follow the pattern given in the examples.
For full marks, do not use any compound Boolean expressions in the questions of your conditional
expressions( i.e. for full marks, do not use and and or ).
;;weather-message: num string → string
;;produces a string combining a temperature message with another string
;;describing current conditions. The message for the tempeSrature is:
Temperature t Temperat...
View Full Document
This note was uploaded on 10/24/2009 for the course CS 115 taught by Professor Graham during the Fall '08 term at Waterloo.
- Fall '08