Isoraqathedh

Write the array

Mar 24th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.01 KB | None | 0 0
  1. (defun write-in-diagram-array (diagram destination-descr &optional force-char)
  2.   (destructuring-bind (y x &rest args) destination-descr ; again, reversed x-ys in arrays
  3.     (let ((centre-of-array-x (floor (/ (first (array-dimensions diagram)) 2)))
  4.       (centre-of-array-y (floor (/ (second (array-dimensions diagram)) 2))))
  5.       (labels ((write-functor (x y char)
  6.          (setf (aref diagram (- (first (array-dimensions diagram)) (+ x centre-of-array-x 1)) (+ y centre-of-array-y)) char))
  7.            (select-character (args default)
  8.          (if force-char force-char (cond
  9.                          ((getf args :igui) "!")
  10.                          ((and (getf args :move)
  11.                            (not (getf args :capture))) "m")
  12.                          ((and (getf args :capture)
  13.                            (not (getf args :move))) "c")
  14.                          (t default)))))
  15.     ;; (cond
  16.     ;;   ((getf args :range)
  17.     ;;    (cond ((= x y)
  18.     ;;    (if (eql (getf (getf args :range) :distance) :infinite)
  19.     ;;        (loop for i from (1+ centre-of-array-x) below
  20.     (write-functor x y (select-character args "x"))
  21.     diagram))))
Advertisement
Add Comment
Please, Sign In to add comment