Remarks: Maze Walker

From Maze

(Difference between revisions)
Jump to: navigation, search
(Created page with 'The abstract visual pattern produced by 10-print can be appreciated purely for its formal, compositional qualities, like an abstract painting or a fabric pattern. [reference othe…')
Line 8:Line 8:
1 PRINT CHR$(205.5 + RND(1));
1 PRINT CHR$(205.5 + RND(1));
 +
2 PRINT CHR$(205.5 + RND(1));
2 PRINT CHR$(205.5 + RND(1));
 +
…
…
 +
400 PRINT CHR$(205.5 + RND(1));
400 PRINT CHR$(205.5 + RND(1));
 +
There are, however, significant problems with writing the program this way. For one thing, the program is long; the programmer must engage in the repetitive task of writing the same line over and over again (changing the line numbers). Computers are good at repetition; whenever a program involves tedious and repetitive steps, programmers look for ways to make the computer do the repetitive work. More significantly, this version of the program is very hard to change. To create a longer sequence of 600 symbols, 200 more lines must be added to the program. To create a shorter sequence of 100 symbols, 300 lines must be deleted from the program. To create a pattern of two different symbols, or to change the relative frequency with which the two symbols appear, the number 205.5 must be changed in every line. Clearly the best way to write this program is to write the PRINT line once and have the computer execute the line 400 times. The program must somehow count to 400, so that it can keep track of how many times it has executed the PRINT line and stop after 400 times. The following program does this, introducing the FOR NEXT construct in BASIC.
There are, however, significant problems with writing the program this way. For one thing, the program is long; the programmer must engage in the repetitive task of writing the same line over and over again (changing the line numbers). Computers are good at repetition; whenever a program involves tedious and repetitive steps, programmers look for ways to make the computer do the repetitive work. More significantly, this version of the program is very hard to change. To create a longer sequence of 600 symbols, 200 more lines must be added to the program. To create a shorter sequence of 100 symbols, 300 lines must be deleted from the program. To create a pattern of two different symbols, or to change the relative frequency with which the two symbols appear, the number 205.5 must be changed in every line. Clearly the best way to write this program is to write the PRINT line once and have the computer execute the line 400 times. The program must somehow count to 400, so that it can keep track of how many times it has executed the PRINT line and stop after 400 times. The following program does this, introducing the FOR NEXT construct in BASIC.

Revision as of 12:56, 22 September 2010

View this revision of Remarks: Maze Walker.

Personal tools