title: Not able to use let in Racket
body: <p>I am trying a modification of sort code on <a href="http://home.adelphi.edu/~siegfried/cs270/270rl10.html" rel="nofollow">http://home.adelphi.edu/~siegfried/cs270/270rl10.html</a> where I am using let for the insert function: </p>
  
  <pre><code>(define (mysort alon ) 
    (let insert ((n n) (alon  alon)) 
      (cond 
        [(empty? alon) (cons n empty)] 
        [else (cond 
                [(&lt; n (first alon)) (cons n alon)] 
                [else (cons (first alon) 
                            (insert n (rest alon))])])
    (cond 
      [(empty? alon) empty] 
      [(cons? alon) (insert (first alon) 
                             (mysort (rest alon)))])))
  
  (mysort (list 1 2 3 4 5 6 2 3 1 4 5 2 10))
  </code></pre>
  
  <p>However, it is not working at level of 'let' variable declaration : </p>
  
  <pre><code>n: unbound identifier in module in: n
  </code></pre>
  
  <p>I see here (<a href="https://docs.racket-lang.org/reference/let.html" rel="nofollow">https://docs.racket-lang.org/reference/let.html</a>) that 'let' needs to have initial values of variables. Can we use 'let' without initializing the variables? How can above code be corrected?</p>
  
  <hr>
  
  <p>Edit: I tried  to use lambda but it does not work:</p>
  
  <pre><code>(define (mysort4 alon ) 
    (let ([insert4
           (lambda (n alon) 
             (cond 
               [(empty? alon) (cons n empty)]
               [(&lt; n (first alon)) (cons n alon)] 
               [else (cons (first alon) 
                           (insert4 n (rest alon) ))]))])
      (cond 
        [(empty? alon) empty] 
        [(cons? alon) (insert4 (first alon) 
                               (mysort4 (rest alon) ) )])))
  
  (mysort4 (list 1 2 3 4 5 6 2 3 1 4 5 2 10))
  </code></pre>
  
  <p>The error is: </p>
  
  <pre><code>insert4: unbound identifier in module in: insert4
  </code></pre>