Skip to content

"successful-move" to "user-entered-valid-move" and "user-entered-invalid-move" #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/cftbat/functional-programming.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ <h3><a id="Anchor-13"></a>Code Organization</h3>
<span class="tok-p">(</span><span class="tok-nf">require</span> <span class="tok-p">[</span><span class="tok-nv">clojure.set</span> <span class="tok-ss">:as</span> <span class="tok-nv">set</span><span class="tok-p">])</span>
<span class="tok-p">(</span><span class="tok-ss">:gen-class</span><span class="tok-p">))</span>

<span class="tok-p">(</span><span class="tok-kd">declare </span><span class="tok-nv">successful-move</span> <span class="tok-nv">prompt-move</span> <span class="tok-nv">game-over</span> <span class="tok-nv">query-rows</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-kd">declare </span><span class="tok-nv">user-entered-valid-move</span> <span class="tok-nv">user-entered-invalid-move</span> <span class="tok-nv">prompt-move</span> <span class="tok-nv">game-over</span> <span class="tok-nv">query-rows</span><span class="tok-p">)</span>
</code></pre></div></div>

<p class="Body">I’ll explain the functions here in more detail in Chapter 6. If you’re <span>curious about what’s going on, the short explanation is that </span><code>(</code><code>require </code><code>[</code><code>clojure</code><code>.set :as set])</code><span> allows you to easily use functions in the </span><code>clojure.set</code><span> namespace, </span><code>(:gen-class)</code><span> allows you to run the program from the command </span>line, and <code>(declare successful-move prompt-move game-over query-rows)</code> 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<a id="Anchor-14"></a>.</p>
<p class="Body">I’ll explain the functions here in more detail in Chapter 6. If you’re <span>curious about what’s going on, the short explanation is that </span><code>(</code><code>require </code><code>[</code><code>clojure</code><code>.set :as set])</code><span> allows you to easily use functions in the </span><code>clojure.set</code><span> namespace, </span><code>(:gen-class)</code><span> allows you to run the program from the command </span>line, and <code>(declare user-entered-valid-move user-entered-invalid-move prompt-move game-over query-rows)</code> 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<a id="Anchor-14"></a>.</p>
<h3>Creating the Board</h3>
<p class="BodyFirst">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 <code>:rows</code> key, storing the total number of rows. Figure 5-3 shows a board with each position numbered.</p>
<img src="/assets/images/cftbat/functional-programming/peg-thing-data-structure.png" class="figure" />
Expand Down