Langton's ant: Difference between revisions

Add Seed7 example
(Add Nimrod)
(Add Seed7 example)
Line 4,001:
....................................................................................................
....................................................................................................</pre>
 
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
 
const type: direction is new enum UP, RIGHT, DOWN, LEFT end enum;
const proc: main is func
local
const integer: width is 75;
const integer: height is 52;
var array array boolean: m is height times width times FALSE;
var direction: dir is UP;
var integer: x is width div 2;
var integer: y is height div 2;
begin
while x in {1 .. width} and y in {1 .. height} do
dir := direction conv ((ord(dir) + 2 * ord(m[y][x]) - 1) mod 4);
m[y][x] := not m[y][x];
case dir of
when {UP}: decr(y);
when {RIGHT}: decr(x);
when {DOWN}: incr(y);
when {LEFT}: incr(x);
end case;
end while;
for key x range m do
for y range 1 to width do
write(".#"[succ(ord(m[x][y]))]);
end for;
writeln;
end for;
end func;</lang>
 
{{out}}
<pre>
...........................................................................
...........................................................................
...........................................................................
............................##..############..##...........................
...........................#..####..........#..##..........................
..........................###...##............##.#.........................
..........................#.#..#.........#..#....#.........................
......................##..##.#.#.........###.......#.......................
...................###.#..#...#.....#.....##.##..###.......................
....................#.#..###..##.####.##...#.#..#.##..##...................
....................#.###.##..#.##..###.#.#.....###...###..................
..................#.....#...#####.#.#..####..#...###.#.#.#.................
.................###.##...#.####..##.##.######.#.###.#...#.................
.................#.###.#.##.#.#.##.##.##.#...#####.###.##..................
.....................#.#...#.##.###...#...#.#..####....#.##................
..................#..#.........##.##...#..##.....##.#.....##...............
.................###...#.#.##.###..#..##.....#...###.##..##.#..............
................#..###..##...##.##...###..#....#..##.####...#..............
...............###...#...#.#..#.#.####.##..#.##.###..#.....#...............
..............#..###..#.##....#..#.###..#......###.##.#..#..##.............
.............###...#.....#.##.#.##..##..#####.####..####.##...#............
............#..###..#.#.#..#.###.#.#.##......##...#.#.#....#...#...........
...........###...#..##.###..##.#...##.......####.####...#......#...........
..........#..###..#.#..#...##..###########.#..####..#....#....#............
.........###...#..##......#.####..##..#########..#..##....#..##............
........#..###..#.#...##..#.##...##.##.###.###...#..#.##..####.#...........
.......###...#..##...#..#.######.##.#.##.#.#....###.###...##...#...........
......#..###..#.#...#.....#####.#.#####.....#.#..##.#....##...#............
.....###...#..##....#.....#.##.#####.##..#.#...#..#..##.#..#..#............
....#..###..#.#.....#....#...####.#..#####.##...##########...##............
...###...#..##......#.##...##...#..#...####..#...##.####.##................
..#..###..#.#........#####.#..##...##.#...#....#.#..#..#..#.#..............
.###...#..##..........##..##.#.#.#....##.##.#.#.##..#..##..##..............
#..###..#.#.................#..#....#.########.#.#.##..####.#..............
.###.#..##..................#..#...#.......##.##...#..#..##.#..............
#.#.#.#.#....................#..#..#......#..##..##...##.####..............
.####.##......................##...#.......##..##....#...#.###.............
.#.##.#............................#.##..####....####.###.####.............
..####..............................##..####....##..#.##.#.#..#............
...##................................##....##....##.###.##.#####...........
....................................................#.##.#..####...........
........................................................##.##.##...........
........................................................##.................
......................................................#.##..####.#.........
.....................................................#..#.###..###.........
.....................................................#.##.#..#..#..........
......................................................##......##...........
.......................................................##..................
...........................................................................
...........................................................................
...........................................................................
...........................................................................
</pre>
 
=={{header|Sidef}}==