Tic-tac-toe: Difference between revisions

→‎J: Attempt to fix syntax highlighting issue
(→‎J: Add number display for selecting squares)
Tags: Mobile edit Mobile web edit
(→‎J: Attempt to fix syntax highlighting issue)
Tags: Mobile edit Mobile web edit
Line 6,686:
 
=={{header|J}}==
<syntaxhighlight lang="j">Until=: {{[F.(u[_2:Z:v)}} NB. apply u until v is true
Until=: {{[F.(u[_2:Z:v)}} NB. apply u until v is true
'Marks State'=:'.OX' ; 10{.1
'`errmsg turn board'=: echo@'no'`{.`}. NB. get turn/board from state vector
'`available full'=: (0=[{board@])`(0-.@e.board)
you_move=: $:@errmsg^:(-.@e.i.@9)@:<:@".@(1!:1@1)
Line 6,699 ⟶ 6,700:
prompt=: echo@:>:@i.@3 3@echo@'you''re X''s. enter a move (1–9) each turn as below:'
ttt=: outcome@(show@move Until (won+.full))@State@prompt
NB. use: ttt 0 (arg is ignored)</syntaxhighlight>
</syntaxhighlight>
Sample play:
 
11

edits