a7q4 - CS 116 Ru Wang r46wang 20319247 Assignment 7...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
## CS 116 Ru Wang r46wang 20319247 ## Assignment 7 Question 4 ## print_row: (listof string) -> void ## this function consumes a list of string, but does not produce anything ## Effects: it displays the parameters in the list with commas inserted in between. ## Examples: ## print_row([]) => "" ## print_row(["hi"]) => "hi" ## print_row(["a","b","c"]) => "a, b, c" def print_row(row): display = "" length = len(row) num = 0 while (num < length): display = display + row[num] if (not ( length == num + 1)): display = display + ", " num = num + 1 print display ##Testings: ## print_row([]) print "Test 1" print "Expect to See: " print "" print "Actual output follows: " print_row([]) ## print_row(["hi"]) print "Test 2" print "Expect to See: " print "hi" print "Actual output follows: " print_row(["hi"]) ## print_row (["a", "b", "c"]) print "Test 3" print "Expect to see: " print "a, b, c" print "Actual output follows" print_row(["a","b","c"]) ## print_table: (listof (listof string)) int -> void ## consumes a list of a list of string and a integer indicating the length of the list, and produces nothing ## Effects: it prints out each list of string within the list on a line with comma and space in between each element. ## Examples:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/21/2010 for the course CS 116 taught by Professor T.vasiga during the Fall '09 term at Waterloo.

Page1 / 4

a7q4 - CS 116 Ru Wang r46wang 20319247 Assignment 7...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online