;; 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 "2017-fall-reader.rkt" "csc104")((modname Week-6-Lab) (compthink-settings #hash((prefix-types? . #f))))
; Exercises for Week 6
; ====================
; The quiz on October 18th will be related to this exercise.
; You should do very well on the quiz if you try out everything below.
; Instructors/TAs are available before quizzes for questions, 10--3 on Wednesday in BA 3175.
; Quiz Rooms
; ----------
; TUT0201 11-12
; 11:30 surnames A--L RS310
; 11:30 surnames M--V HA316
; 11:45 surnames W--Z RS310
;
; TUT0301 12--1
; 12:30 surnames A--M BF323
; 12:45 surnames N--Z BF323
;
; TUT0401 1--2
; 1:30 surnames A--M UC256
; 1:45 surnames N--Z UC256
;
; TUT0501 2--3
; 2:30 surnames A--M RS310
; 2:45 surnames N--Z RS310
;
; TUT0101 3--4
; 3:30 surnames A--M RW140
; 3:45 surnames N--Z RW140
; Examine this function definition.
; f : number → boolean
(define (f n)
(or (zero? n)
(and (positive? n)
(f (- n 2)))))
; Show the steps to evaluate:
#;(f -1)
#;(f 0)
; Check your work:
#;(step (f -1))
#;(step (f 0))
; Show the steps to evaluate the following expression.
; If the steps involve (f -1) or (f 0), you may simply use the values you already calculated,
; instead of showing how to step those again.
#;(f 1)
; The step form can be told to hide the steps for particular function calls.
; The following expression shows the steps for (f 1), omitting any steps for (f -1) or (f 0),
; so you can check your work:
#;(step (hide (f -1) (f 0))
(f 1))
; Show the steps to evaluate the following expressions.
; If the steps involve expressions you already stepped, you may simply use the values you already
; calculated instead of showing how to step those again.
#;(f 2)
#;(f 3)
; Here are the corresponding step expressions, to check your work:
#;(step (hide (f -1) (f 0) (f 1))
(f 2))
#;(step (hide (f -1) (f 0) (f 1) (f 2))
(f 3))