Langton's ant: Difference between revisions

Content added Content deleted
(→‎{{header|D}}: Add Common Lisp)
(→‎{{header|Common Lisp}}: Break out display logic.)
Line 720: Line 720:
(3 (decf x)))
(3 (decf x)))
)
)
grid
(dotimes (y height)
)
)

(defun show-grid (grid)
(destructuring-bind (width height) (array-dimensions grid)
(dotimes (y height)
(dotimes (x width)
(dotimes (x width)
(princ (if (aref grid x y) "#" ".")))
(princ (if (aref grid x y) "#" ".")))
Line 728: Line 734:


(setf *random-state* (make-random-state t))
(setf *random-state* (make-random-state t))
(langtons-ant 100 100 (+ 45 (random 10)) (+ 45 (random 10)) (random 4))</lang>
(show-grid (langtons-ant 100 100 (+ 45 (random 10)) (+ 45 (random 10)) (random 4)))</lang>

=={{header|D}}==
=={{header|D}}==
{{incorrect|D|The chirality of the output is reversed, meaning the ant is turning left when the spec says it should turn right, and vice-versa.}}
{{incorrect|D|The chirality of the output is reversed, meaning the ant is turning left when the spec says it should turn right, and vice-versa.}}