Search code examples
schemerackethtdp

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


(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)


Solution

  • 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.