Tuesday, March 19, 2013

Recursion

Today in class, we learned about recursion. At first, I was confused as to how to approach the coding. But doing it together with the class really helped and I was able to do some parts of the questions by myself.

However, I still have a problem describing the coding in picture.
For example:
In the recursion handout given out in class, the following expression is shown:

; s : number -> image
(define (s d)
    (cond
       [(> d 0)
         (beside/align "bottom"
                              (line 0 (+ 5 (* 2 d)) "red")
                              (rotate 90 (s (- d 1 ))))]
        [else (line 0 5 "red")]))

So I don't understand how (s 2) looks like
I had a different interpretation of (s 2). I thought it would look like steps....

No comments:

Post a Comment