title: How do you print only the first solution of backtracking?
body: <p>I am working on the N-queens problem using backtracking in Lisp. So far, my code prints all possible solutions for n>=4. However, I wish to print only the first solution for any value of n. </p>
  
  <pre><code>(defun backtracksearch (row n)
  // (if () *I probably need a line here to stop once the first solution is found*
  (if (&lt; row n)
    (loop for j below n
        do (when (is-safe row j n)
                (setf (aref *chessboard* row j) 'board)
                (backtracksearch (+ 1 row) n)
                (setf (aref *chessboard* row j) 'nil)))
  (print-solution n)))
  </code></pre>
  
  <p>I have tried to use the same implementation/logic as that in the C++ solution of backtracking n-queens. 
  Any advice on the possible way forward would be helpful.</p>