That's the map() function taking care of. Every time loop() runs, it is calculated.
No surprise it doesn't compile. Did you notice setup() is missing as well? There is more missing such as pin declarations indeed (which you can better declare as const byte rather than const int - more efficient). I didn't try to compile it, it's meant to get you started. You have to fill in the rest of the details (and maybe fix some typos in the process).
A pot can be connected easily, and will do great. One end to GND, the other end to Vcc, wiper to A0. That's it.