title: towers of hanoi in common lisp
body: <p>I think this is going to be a vague question because I don't know exactly what I am doing in the first place but here it goes.</p>
  
  <p>I have to do a towers of hanoi problem in common lisp using lists. Basically a function takes a list of strings (names) and then moves them from peg A to peg C using peg B for storage, keeping them in the same order as they were in the list.</p>
  
  <p>I have never used lisp before and I find the syntax very hard to understand. 
  This is my code so far
  goo function is the hanoi work</p>
  
  <pre><code>(defparameter A '())
  (defparameter B '())
  (defparameter C '())
  
  
  (defun findPeg (p1 p2) (cond ((= 0 (- 3 p1 p2))A)  
      ((= 1 (- 3 p1 p2))B) ((= 2 (- 3 p1 p2))C)))
  
  (defun getnum (x) (cond ((equalp x A) 0)((equalp x B)1)((equalp x C) 2)))
  
  (defun hanoi (x) (defparameter A x) (setlength A)(goo len A C B))
  
  (defun setlength(x) (defparameter len (list-length x)))
  
  
  (defun goo (leng from to via) 
  
      (cond ((= leng 1)(push (pop A) C)) ;base case
  
  
  ((goo (1- leng) from via to)(push (pop A)  B) ;say/do something i think
  
  
  ((goo (1- leng) via to from)(push (pop B) C) ;say/do something i think
  
  
  ))))
  </code></pre>
  
  <p>My problem is with the recursive calls. I am very confused as to what exactly I should be doing. I know I obviously have to move the first string in the first list to another peg, but I don't know which peg or even how to manipulate the lists. I feel like I should be using the variables that were passed into the goo function, but I cant figure out how to edit them because when I change them in the function the variables outside do not change.</p>
  
  <p>Right now I am running into the error</p>
  
  <p><em>*</em> - SYSTEM::%EXPAND-FORM: (GOO (1- LENG) FROM VIA TO) should be a lambda expression</p>
  
  <p>This is a recursive call so I don't know why it is saying that.</p>
  
  <p>Basically I just want some tips or tricks on where do continue or ever where to restart because I don't even know if my approach is a good one.
  Anything is greatly appreciated. Thanks</p>