Recursion seems to be the first kind of "function" we have learned in CSC148 so far. Previous weeks were focusing on classes, which I used to be confused with, but started getting better. Functions are the parts in programming I like and good at, unlike classes. But does this make sense? Methods in class are just functions we create outside of class, how come I am confused with methods but not functions? To be honest I have no idea. It just seems like putting stuff all together is confusing and hard to understand and organize?
Anyways, recursion seems to be an interesting topic I have never seen before. It takes the function you write in side the function itself, which is really cool. This reminds me of the "clever" function my instructor taught in the last chapter of CSC165, which is about computability. And the "clever" function proved halt function did not halt or something...
The knowledge in CSC108 is getting back to my mind gradually during labs. For instance, last week's lab was about recursion, and the last function took me quite a few time. The reason seemed not to be that I did not understand recursion. I kind of forget that in order to put two lists together, I should just put a "+" sign between them. With the help of TA, I realized that. Surprisingly, it appeared on the test..
My impression for recursion is that if you put it only in one function consisting "if" and "else", it is easy to understand. However, if there are more lines before "if", this may cause confusion. For example, I want to set a variable or something, and when I call the function in "if", it will also set a variable again and again? I am not sure actually, and a little bit confused with this part which was not discussed in class, or maybe it just does not work in that case.
No comments:
Post a Comment