Anonymous user
Tic-tac-toe: Difference between revisions
→{{header|Tailspin}}: update to stricter typing
(Added Forth entry) |
(→{{header|Tailspin}}: update to stricter typing) |
||
Line 13,794:
<lang tailspin>
processor Tic-Tac-Toe
@: [position´1..
source isWonOrDone
Line 13,801:
$@Tic-Tac-Toe([1,5,9]) -> #, $@Tic-Tac-Toe([3,5,7]) -> #
] -> \(
when <=[]?($@Tic-Tac-Toe <~[<
when <~=[]> do $(1) !
\) !
when <[<mark>+ VOID]?($ <[<=$(first)
end isWonOrDone
source validMoves
$@Tic-Tac-Toe -> \[i](<
end validMoves
Line 13,829:
source play
def board: $Tic-Tac-Toe;
@: mark´'X';
templates getMove
[] -> #
Line 13,837:
[{mark: $@play, position: $IN::readline -> toInt} -> board::move] -> #
otherwise
$(1) !
end getMove
Line 13,843:
when <{}> do
'$.mark; played $.position;$#10;' -> !OUT::write
@: $@ -> \(<=mark´'X'> mark´'O'! <=mark´'O'> mark´'X' !\);
[$board::isWonOrDone] -> \(
when <=[]> do $getMove!
|