What is ws in the big-bang function really representing?

220 Views Asked by At
(big-bang ws
          (on-tick cth)
          (on-key keh)
          (on-mouse meh)
          ...)

I know that the first parameter is a number and it's the described as the world state. But that just seems like vague terminology to me. Basically I don't understand what this number is really/actually supposed to represent. Two examples I've seen so far are: "countdown mechanism" and "number of pixels to be moved". What exactly is it doing?

I am working Chapter 2 on HtDP (2nd Edition)

2

There are 2 best solutions below

1
On BEST ANSWER

The world represent the current state of the program. In some program the entire state can be represented as a single number (e.g. a ufo that only moves up and down). It is rare that a single number is enough though. To represent the position of a space ship that can move in all directions, you need both an x- and a y-coordinate. Since the world must be a single value the two numbers are put into a structure. The following chapters in HtDP will introduce you to structures and how to use them as worlds.

0
On

I did not realize that the first parameter of type any/c. Which, for the uninitiated, means that the first parameter can be any type (ex: integer, string, boolean, structure, enumeration, etc). So in the examples I was working on, the big-bang function was using an integer as the simplest form of state. In using an integer as the state, the function is able to do things like manipulate the countdown clock and move the rocket by a certain number of pixels.