title: Recursive backtracking in Racket?
body: <p>A while ago, as a proof of concept (and because I was using Logo with my autistic son) I wrote a program in Logo to find a Hamiltonian circuit in a graph (if it exists) using a backtracking method.  The basic backtracking schema I used was:</p>
  
  <pre><code>boolean hamilton(path p, graph g) 
    {
    if p has as many vertices as g 
      {
      if the last and first vertices in p are adjacent, 
        return true
      else 
        return false
      } 
    else 
      {
      for each vertex x of g not in p and adjacent to the last vertex of p
        {
        if hamilton(path p + x,graph g) succeeds, 
          return true
        }
      return false
      }
    }
  </code></pre>
  
  <p>and you can see a discussion <a href="http://www.cis.upenn.edu/~matuszek/cit594-2012/Pages/backtracking.html" rel="nofollow noreferrer">here</a>.  I could do this easily in Logo because it allows multiple exit points from a function with the <code>OUTPUT</code> command.</p>
  
  <p>However, Racket doesn't allow multiple exit points (at least, not easily).  So I'm hoping to be pointed in the direction of some material which would explain (a) how to manage multiple exit points from a function (I have a vague notion I can do it with continuations, as with <code>let/ec</code>) or (b) how to manage recursive backtracking in Racket in a way maybe better suited to the language.  </p>
  
  <p>As a newcomer to Racket, I'm sure this could be done in the twinkling of an eye by an expert, or even by anybody less of a raw beginner then me.  But right now I fund myself quite stumped.  Thanks!</p>