<div dir="ltr">Ah yes, that is nicer! I got too used to the limitations of the other languages I use :)<div><br></div><div style>Peter</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 March 2013 03:16, Lyndon Maydwell <span dir="ltr">&lt;<a href="mailto:maydwell@gmail.com" target="_blank">maydwell@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If taking the array approach, I&#39;d recommend using a single array indexed by the (x,y) position of the cell, this way neither direction has a greater implied significance. Diagonals should also be easier.<div>



<br></div><div>Aside: Tony Morris wrote a very interesting exercise based on tic-tac-toe and it is available on Hackage: <a href="http://hackage.haskell.org/package/TicTacToe" target="_blank">http://hackage.haskell.org/package/TicTacToe</a></div>



</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 19, 2013 at 3:49 AM, Peter Hall <span dir="ltr">&lt;<a href="mailto:peter.hall@memorphic.com" target="_blank">peter.hall@memorphic.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Start with a data type for the cell values, instead of Char. Then use an Array of Arrays, containing those values.<div>



<br></div><div>data Cell = Empty | O | X</div><div>type Board = Array Int Cell</div>

<div><br></div><div>Finding winning &quot;rows&quot; and &quot;columns&quot; is easy. Diagonals are slightly more complicated. </div><span><font color="#888888"><div><br></div><div>Peter</div>
<div><br></div></font></span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 March 2013 15:54, Costello, Roger L. <span dir="ltr">&lt;<a href="mailto:costello@mitre.org" target="_blank">costello@mitre.org</a>&gt;</span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Folks,<br>
<br>
Currently I am representing a tic-tac-toe board as a string, with &#39;X&#39; denoting player 1 and &#39;O&#39; denoting player 2. For example, I represent this 2x2 game board:<br>
<br>
     &#39;X&#39;        |<br>
-----------------------<br>
        |   &#39;O&#39;<br>
<br>
with this string: &quot;X  O&quot;<br>
<br>
The nice thing about that representation is that it is each to identify which cells are filled or empty, and it is easy to mark a cell with an &#39;X&#39; or &#39;O&#39;.<br>
<br>
The problem with the representation is that it is difficult to determine when a player has won.<br>
<br>
Can you recommend a representation that makes it easy to:<br>
<br>
1. determine when a player has won<br>
2. identify cells that are filled or empty<br>
3. mark an empty cell<br>
<br>
/Roger<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>