Strict Standards: Declaration of Doku_Renderer_metadata::table_open() should be compatible with Doku_Renderer::table_open($maxcols = NULL, $numrows = NULL, $pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 24

Strict Standards: Declaration of Doku_Renderer_metadata::table_close() should be compatible with Doku_Renderer::table_close($pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 24

Lab 5

  • Example of recursion: Using VPython to draw an H-tree. 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.
    • Hint: You will want to use the following syntax in your program.
      if type(L) == list:
    • Skeleton:
      def recsum(L):
          ##YOUR CODE HERE
    • Example input:
          >>> recsum([1,2,3])
          >>> recsum([1,2,[3,4,5]])
          >>> recsum([[1,[4,5]],-4,[[6,[7],[9,10]],0]])

Sample Solution

cs190c/lab5.txt · Last modified: 2008/04/18 11:40 by alint
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki