Trees are tricky. They work based on the recursive techniques we've been learning for the past couple of weeks. These techniques served us well for nested objects like lists of lists. So it makes sense that they work for trees, which you are kind of like trees of trees. One new thing we learned that seems to be specific to trees is that we always define the base case to be a leaf (a tree with no children). This case seemed to be present in every module function we wrote for lab 5.
The one thing I still have trouble with is the a if b else c. I can't always predict it's syntax. Whenever it's inside a list comprehension, I don't seem to need the else. When it's anywhere else, however, it needs the "else" at the end. I'm not always sure what to put as the result however.
Anywho, another week, another opportunity for learning!
No comments:
Post a Comment