For a homework assignment I have to (amongst other things) create a chess board in Oz.
I'm rather unfamiliar with the language but here's how I wanted to do it:
declare
fun {MakeTile Col Row}
if Col==1 then
if {And (Row=<10) (Row>=2)} then N in
N = {MakeTile 1 Row+1}|{MakeTile 1 Row-1}|{MakeTile 2 Row}|{MakeTile 2 Row-1}
tile(column:Col row:Row player:0 neighbours:N)
else
if Row==11 then N in
N = {MakeTile 1 Row-1}|{MakeTile 2 Row-1}|{MakeTile 2 Row}
tile(column:Col row:Row player:0 neighbours:N)
else N in % Row==1
N = {MakeTile 1 Row+1}|{MakeTile 2 Row}
tile(column:Col row:Row player:0 neighbours:N)
end
end
else
tile(column:Col row:Row player:0 neighbours:nil)
% TODO: Handle other edge of the board
end
end
{Browse {MakeTile 'A' 1}}
The program just keeps running.
We have to program in a declarative style. I'm not used to these kinds of languages, is the recursive approach the good way to create such a board?