summaryrefslogtreecommitdiffstats
path: root/articles/tictactoe/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'articles/tictactoe/index.html')
-rw-r--r--articles/tictactoe/index.html10
1 files changed, 7 insertions, 3 deletions
diff --git a/articles/tictactoe/index.html b/articles/tictactoe/index.html
index c7a10a36..85fbb025 100644
--- a/articles/tictactoe/index.html
+++ b/articles/tictactoe/index.html
@@ -74,7 +74,7 @@
<p>Writing an algorithm to check for victory sounds easy, right? It&apos;s easily tested, considering there&apos;s only 8 possible winning rows (3 horizontal, 3 vertical and 2 diagonal).</p>
<p>In Erlang though, you probably wouldn&apos;t want an algorithm. Erlang has this cool feature called pattern matching which will allow us to completely avoid writing the algorithm by instead letting us match directly on the solutions.</p>
<p>Let&apos;s first create a board. A board is a list of 3 rows each containing 3 columns. It can also be thought of as a tuple containing 9 elements. A tuple is easier to manipulate so this is what we are going to use. Each position can either contain an <code>x</code>, an <code>o</code>, or be <code>undefined</code>.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -84,7 +84,7 @@ http://www.gnu.org/software/src-highlite -->
<font color="#000080">undefined</font>, <font color="#000080">undefined</font>, <font color="#000080">undefined</font>}<font color="#990000">.</font></tt></pre>
</div></div>
<p>Now that we have a board, if we want to play, we need a function that will allow players to, you know, actually play their moves. Rows and columns are numbered 1 to 3 so we need a little math to correctly deduce the element&apos;s position.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -93,7 +93,7 @@ http://www.gnu.org/software/src-highlite -->
</div></div>
<p>This function returns the board with the element modified. Of course, as you probably noticed, we aren&apos;t checking that the arguments are correct, or that the element was already set. This is left as an exercise to the reader.</p>
<p>After playing the move, we need to check whether someone won. That&apos;s where you&apos;d write an algorithm, and that&apos;s where I wouldn&apos;t. Let&apos;s just pattern match all of them!</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -134,6 +134,10 @@ http://www.gnu.org/software/src-highlite -->
+ <li><a href="https://ninenines.eu/articles/cowboy-2.7.0/">Cowboy 2.7</a></li>
+
+
+
<li><a href="https://ninenines.eu/articles/gun-2.0.0-pre.1/">Gun 2.0 pre-release 1</a></li>