diff --git a/content/cftbat/functional-programming.html b/content/cftbat/functional-programming.html index 19db1dd6..1964da6e 100644 --- a/content/cftbat/functional-programming.html +++ b/content/cftbat/functional-programming.html @@ -353,10 +353,10 @@

Code Organization

(require [clojure.set :as set]) (:gen-class)) -(declare successful-move prompt-move game-over query-rows) +(declare user-entered-valid-move user-entered-invalid-move prompt-move game-over query-rows) -

I’ll explain the functions here in more detail in Chapter 6. If you’re curious about what’s going on, the short explanation is that (require [clojure.set :as set]) allows you to easily use functions in the clojure.set namespace, (:gen-class) allows you to run the program from the command line, and (declare successful-move prompt-move game-over query-rows) allows functions to refer to those names before they’re defined. If that doesn’t quite make sense yet, trust that I will explain it soon.

+

I’ll explain the functions here in more detail in Chapter 6. If you’re curious about what’s going on, the short explanation is that (require [clojure.set :as set]) allows you to easily use functions in the clojure.set namespace, (:gen-class) allows you to run the program from the command line, and (declare user-entered-valid-move user-entered-invalid-move prompt-move game-over query-rows) allows functions to refer to those names before they’re defined. If that doesn’t quite make sense yet, trust that I will explain it soon.

Creating the Board

The data structure you use to represent the board should make it easy for you to print the board, check whether a player has made a valid move, actually perform a move, and check whether the game is over. You could structure the board in many ways to allow these tasks. In this case, you’ll represent the board using a map with numerical keys corresponding to each board position and values containing information about that position’s connections. The map will also contain a :rows key, storing the total number of rows. Figure 5-3 shows a board with each position numbered.