title: Flattening a tree structure in Lisp
body: <p>I was struggling with flattening a tree structure. I was doing it recursively by comparing each atomic symbol to the rest in the tree but, a friend of mine suggested the following code which I think looks cleaner. I just don't understand the line:</p>
  
  <pre><code>((atom tree)(list tree))
  </code></pre>
  
  <p>I understand what each of them do individually, I also know that the loop below takes a list or it causes an error, which I suspect has a lot to due with the reason we're turning the symbol into a list if atom returns true. But I still don't feel like I fully understand the code.  </p>
  
  <pre><code>(defun flatten (tree)
  (cond ((null tree)
       nil
       )
      ((atom tree)(list tree))
      (t
       (loop for a in tree appending (flatten a)))))
  </code></pre>
  
  <p>An explanation would terrific if anyone could spare the time? Thanks!</p>