Saturday, 9 November 2013

Recursion Technique of Dr.Racket

Recently, we have been learning about a new technique of writing codes. The technique is to have a function call on itself within the function. This is called "Recursion". An example of the recursion would be:
   

  (define X n
          (cond ((zero? n) (square 10 outline black)
                       (else (beside
                              (X (- n 1)) (X(- n1)) 
                        ) 
                     )
            )
      )

This means when n is zero, a size 10 black square would be produced.
When n is 1, two size 10 black square would be produced side by side.
When n is 2, four size 10 black square would be prodcued side by side....

This function fascinates me as the image would be significantly larger for each increase of the value n. Also, a patter can be seen after trying out several values of n.

However, I feel that some slightly more complicated functions that use this recursion technique may be hard to understand at  time. I feel like the quiz I did for this material last week did not go well as a lot of time was spent on figuring out the difference between n=0 and n=1.

I would have to spend more time and effort on this section of Dr.Racket in order to identify the codes faster.
More time would be spent on studying the term test for this coming week.


No comments:

Post a Comment