lisp: building a list of lists from a single list
<p>I am trying to take a list of 16 numbers I have and make it into a list of 4, 4 element sublists to represent the game board of a magic square. I made a method that can take a list and return a single sublist, and now I am trying to recursively use this method to build the full board. </p>

<p>My problem however, is my initBoard returns nil no matter what and I know every other method is working as desired. Any clarification of my error would be greatly appreciated! </p>

<p>Also here is an example input list:</p>

<p>(4 5 15 10 14 11 1 8 9 16 6 3 7 2 12 13)</p>

<p>And what I want as the output would be:</p>

<p>((4 5 15 10) (14 11 1 8) (9 16 6 3) (7 2 12 13))</p>

<pre><code>(defun smallList (lst cnt)
   (cond ((&gt;= cnt 4) nil)
   (t (cons (car lst) (smallList (cdr lst) (+ 1 cnt))))))

(defun isEmpty (lst)
   (if lst 1 -1))

(defun initBoard (lst)
   (cond ((= (isEmpty lst) -1) nil) 
   (t (cons (smallList lst 0) (initBoard  (cddddr lst))))))
</code></pre>