CSE 1010 Lecture 12: Nested Loops part 2, Refactoring

50 views3 pages
Verified Note

Document Summary

Rewriting the program to get rid of unnecessary parts of the program; improves the structure without changing the behavior: usually shortens the function. The row variable is unused, and can be replaced with its value of eld[rownum] This removes the need for the assignment statement as well. The row variable is only used once, and can also be replaced with its value of. Instead of calling plantsquare, we can replace the plantsquare function with value of eld[rownum][colnum] = 1. !1: this removes the need for de ning the plantsquare function, since its never called from plantrow, so it can be deleted. !2: if the outer loop iterates 10 times, then the inner loop starts 10 times (doesn"t necessarily have to iterate 10 times) Used when there are multidimensional functions; lists of lists. A starts at 0, and the b loop run through 0-2 before a can progress to 1.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers