CS115W2009M2

G snowing sunny etc the string produced should follow

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 available. ;; 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online