Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why this no work?

Name: Anonymous 2011-04-21 11:41

;___;



(defmacro get-pos (board x y)
  `(nth ,y (nth ,x ,board)))

(defun cell-times (lst &optional (acc 0))
  (if lst
      (cond ((eq (car lst) nil)
         (cell-times (cdr lst) acc))
        ((numberp (car lst))
         (cell-times (cdr lst) acc))
        (t (cell-times (cdr lst) (1+ acc))))
      acc))
 
(defun get-if-possible (board x y) ;X och Y felet ligger här!?
  (if (not
       (and (>= x (length board))
        (>= y (length (nth 0 board)))))
      (if
       (not (< x 0))
       (if (not (< y 0))
       (get-pos board x y)))))

(defun get-neighbours (board x y)
  (let ((output '() ))
    (push (get-if-possible board (1+ x) y) output)
    (push (get-if-possible board (1- x) y) output)

    (push (get-if-possible board x (1+ y)) output)
    (push (get-if-possible board x (1- y)) output)

    (push (get-if-possible board (1+ x) (1+ y)) output)
    (push (get-if-possible board (1- x) (1- y)) output)

    (push (get-if-possible board (1+ x) (1- y)) output)
    (push (get-if-possible board (1- x) (1+ y)) output)
    output))

(defun next-gen (board) ;Den ändrar board, men hur ><?!
  (let ((output board))
  (loop for x-num from 0 to (1- (length output))
     for x in output do
       (loop for y in x
        for y-num from 0 to (1- (length x)) do
        (let ((neigh-val (cell-times (get-neighbours output x-num y-num))))
          (cond
        ((< neigh-val 2) (setf (get-pos output x-num y-num) neigh-val))
        ((= neigh-val 3) (setf (get-pos output x-num y-num) 'x))
        ((> neigh-val 3) (setf (get-pos output x-num y-num) neigh-val))))))
  output))

Name: Anonymous 2011-04-21 11:56

You should convert tabs to spaces before posting here.

Leaving that aside, what exactly are you trying to accomplish? (I have yet to fully read your code, but it does appear valid, at least syntactically and as far as the compiler is concerned).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List