THIRD WEEK
Another week has passed, during this week of learning in csc104, we got to learn something new, which was condition. Our professor had explained the steps of how it worked quite clear in class, for example, we first define a function
(define (f n ) (or (zero? n) (and positive? n) (f (- n 2))))),
then we sub in a number for n,
(step (f -1)).
The function would run as
(or (zero? -1) (and positive? -1) (f (- -1 2)))))
because 1 does not equal to zero, the first statement would become #false
(or #false (and positive? -1) (f (- -1 2)))))
because -1 is not positive,
(or #false (and #false (f (- -1 2)))))
since there’s a #false in the “and” bracket,
the whole thing would become false
(or #false #false)
#false
This week’s lesson wasn’t too hard, I prepared for the quiz through doing some practices that were posed on the CSC104 website, they were quite helpful.
评论
发表评论