Saturday, 1 March 2014

Required Post: Recursion

    If I could describe recursive code in one sentence, it would be this: repeat the function over and over again, until it does what you want it to do. If I was to describe the degree of understanding it took to wrap my head around that concept, I would consider it high.
   
    At first, I thought recursion was extremely simple. It took a bunch of lines of code and made it into one. The professor made it look so simple. At this point, I hardly knew what recursion even was. Then it happened, I encountered an infinite loop... followed by a few more. Now I need to change my thought process. Now I had to throw up flags in the right spot, to redirect the code to the place I wanted. This was troublesome at first, but most of it makes perfect sense. 

    The part I like most about recursion is that format hardly ever changes. Even though I haven't mastered the ability to do functions in one line, my level of python understanding allows me to complete the code. In essence, all recursion does is recall the function it originates from, and exits when the function is told to. It does make sense. Its also extremely efficient because the process is self-contained within the function itself. All in all, recursion is going to change the way I code from now on.

No comments:

Post a Comment