import IO; import util::Math; import List; public void make_maze(int w, int h){ vis = [[0 | _ <- [1..w]] | _ <- [1..h]]; ver = [["| "| _ <- [1..w]] + ["|"] | _ <- [1..h]] + [[]]; hor = [["+--"| _ <- [1..w]] + ["+"] | _ <- [1..h + 1]]; void walk(int x, int y){ vis[y][x] = 1; d = [, , , ]; while (d != []){ <, d> = takeOneFrom(d); if (xx < 0 || yy < 0 || xx >= w || yy >= w) continue; if (vis[yy][xx] == 1) continue; if (xx == x) hor[max([y, yy])][x] = "+ "; if (yy == y) ver[y][max([x, xx])] = " "; walk(xx, yy); } } walk(arbInt(w), arbInt(h)); for ( <- zip(hor, ver)){ println(("" | it + "" | z <- a)); println(("" | it + "" | z <- b)); } }