Recursion B

More code tracing to understand recursion.

Trace every step.

1.

(define (helper c)
  (cond [(string=? c "light blue")
         "orange"]
        [else "light blue"]))
(define (mystery a x b c)
  (cond [(> a b) empty-image]
        [else
         (overlay (circle a "solid" c)
                  (helper (+ a x)
                            x
                            b
                            (helper c)))]))

Trace:

  1. (helper "pink")
  2. (helper "light blue")
  3. (helper "orange")
  4. (mystery 50 20 60 "orange")
  5. (mystery 50 20 70 "light blue")
  6. (mystery 40 30 120 "orange")

What could make this image?

Last modified February 28, 2025: More recursion tracing practice. (5c5d863)