Well, up until this week, recursion is something I have found the most challenging in this course, which I am still confusing after watching the video.
I studied for quiz 6 last night, and I was confused of the definition.
For example, the definition looks like this:
(define (c n)
(cond [(> n 0) (overlay (c (- n 1))
(circle (* n 5) "outline" "red"))]
[else (circle 1 "outline" "red")]))
After watching the video, I try to understand like this:
Since this is the process of converting number to image, and n should represents a number that is given and applied. Given the number instead of "n", we could apply into the definition just like equation. (c (- n 1)) is the number "n" subtracts 1, which indicates a certain image. The ((circle (* n 5) "outline" "red"))) is the another circle of 5 times the size of the number n. Those two images should be overlaid or beside (according to the definition). If n is not bigger than 0 in this case, it should apply to the "else", which is a red outline circle.
I did this in the quiz and discusses to one of the TAs, she said I was right. I am happy! This is interesting!
No comments:
Post a Comment