I thought Photoshop editing software was cool, now I think DrRacket is cooler :P
Today, I learnt about the concept of recursion where a DrRacket command is defined in such a manner that the command is used within the overall command!
What do i mean? See the following
e.g lets assume i write a command which require a number input "x" to give an output
Input Output
command (x) -----------------------------> ?
whereby, we define "command (x)" as follow
a) if x is 0, then we get output dotdotdot
b) otherwise we use "command (x-1)" to fool around and give an output
Notice how the command is in the overall definition of the command? That is recursion for you!
Check out some interesting things recursion can do:
Input Output
Over here, I have applied some recursion and transformation to drawing circles and it results in some nice patterns :)
Below is another product of recursion with a little randomness incorporated into command for colors. Nice huh?





No comments:
Post a Comment