aboutsummaryrefslogtreecommitdiff
path: root/tictactoe
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2024-03-07 22:14:10 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2024-03-07 22:14:10 +0100
commit911547d0e4e3838fa71cc3f71e5f472114e01431 (patch)
treeb62cee7709fe159a6765378748c7ef28514178fb /tictactoe
parentd6b2edd8cef2a3ab1bb9488fe7e82920a1333af1 (diff)
downloaderlang-workshop-911547d0e4e3838fa71cc3f71e5f472114e01431.tar.gz
erlang-workshop-911547d0e4e3838fa71cc3f71e5f472114e01431.tar.bz2
erlang-workshop-911547d0e4e3838fa71cc3f71e5f472114e01431.tar.xz
erlang-workshop-911547d0e4e3838fa71cc3f71e5f472114e01431.zip
wip
Diffstat (limited to 'tictactoe')
-rw-r--r--tictactoe/ttt/src/ttt.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/tictactoe/ttt/src/ttt.erl b/tictactoe/ttt/src/ttt.erl
index a9fc4d1..f1de18c 100644
--- a/tictactoe/ttt/src/ttt.erl
+++ b/tictactoe/ttt/src/ttt.erl
@@ -45,7 +45,8 @@ move(Board, Move, Row, Col) ->
Updated = lists:sublist(Board, I) ++ [Move] ++ lists:nthtail(I + 1, Board),
{ok, Updated}.
+-spec format(board()) -> chars().
format(Board) when length(Board) == 9 ->
B = lists:map(fun(C) -> case C of 'E' -> ' '; _ -> C end end, Board),
- io:format("+---+~n|~s~s~s|~n|~s~s~s|~n|~s~s~s|~n+---+~n", B);
+ io_lib:format("+---+~n|~s~s~s|~n|~s~s~s|~n|~s~s~s|~n+---+~n", B);
format(_) -> "bad board".