# Differences

This shows you the differences between two versions of the page.

 cs190c:lab5 [2008/02/09 16:24]seh cs190c:lab5 [2008/04/18 11:40] (current)alint Both sides previous revision Previous revision 2008/04/18 11:40 alint 2008/02/09 16:24 seh 2008/02/09 16:24 seh 2008/02/09 16:23 seh 2008/02/09 16:23 seh 2008/02/08 11:26 alint 2008/02/06 19:25 seh 2008/02/06 19:24 seh created 2008/04/18 11:40 alint 2008/02/09 16:24 seh 2008/02/09 16:24 seh 2008/02/09 16:23 seh 2008/02/09 16:23 seh 2008/02/08 11:26 alint 2008/02/06 19:25 seh 2008/02/06 19:24 seh created Line 2: Line 2: * Example of recursion: Using VPython to draw an H-tree. {{cs190c:​htree_rec.py|Source code.}} * Example of recursion: Using VPython to draw an H-tree. {{cs190c:​htree_rec.py|Source code.}} * In-Lab Problem: Write a recursive function that takes as one parameter -- a list with nested lists containing integers. ​ Sum up all the elements. * In-Lab Problem: Write a recursive function that takes as one parameter -- a list with nested lists containing integers. ​ Sum up all the elements. - * Here is a solution: {{cs190c:​recsum.py|}} * Hint: You will want to use the following syntax in your program.<​code python>​if type(L) == list:​ * Hint: You will want to use the following syntax in your program.<​code python>​if type(L) == list:​ * Skeleton:<​code python>​def recsum(L): * Skeleton:<​code python>​def recsum(L): Line 12: Line 11: >>>​ recsum([[1,​[4,​5]],​-4,​[[6,​[7],​[9,​10]],​0]]) >>>​ recsum([[1,​[4,​5]],​-4,​[[6,​[7],​[9,​10]],​0]]) 38​ 38​ + + ===== Sample Solution ===== + * Here is a solution: {{cs190c:​recsum.py|}} +