First thing came into mind about recursion was fractal from mathematics. Repeating same process looked like same shape is repeated in fractal. At first, this didn't seem complex. However, soon after, I could find myself being confused and frustrated. Right, nothing is easy. I forgot about that.
The handout exercise was not hard. But when I tries to write functions, the errors kept rising. I could tell in which part the recursion occurs. The hard part was the implement. It was quite hard where to put recursive one. And considering all relationships between type contract, return value. Consequently, putting them all together was more complicated than I thought.
What I expected to happen with my code often did not work properly. It takes time to get my code work properly. (But it feels like endorphins is spreading to every part of my body fast once I figure it out!) I guess, I am not really understanding how it works yet or need more practice and experiment with practice.
Most of the recursion function bodies were relatively simple and short compares to functions without recursion. Once I solve what exactly recursion does in the function, the solution was simple. All I need to do is think hard to find right recursion case and properly implement.
This is definitely not easy at all. But If I think about what recursion does and how it works, it comes to handy tools when writing some tricky codes. While we are learning this, my goal is to understand recursion and make myself comfortable with it.
No comments:
Post a Comment