title: Racket Intersect Two Lists
body: <p>I am trying to intersect two lists on Racket, but the following code is not working:</p>
  
  <pre><code>(define (intersection a b)
    (if (null? a)
      '()
      (if (contains (car a) b)
        (cond (car a)(intersection (cdr a) b))
        (intersection (cdr a) b))))
  </code></pre>
  
  <p>The result always end up being the first item of list a that is contained in list b, plus the rest of list a. For example:</p>
  
  <pre><code>a = '(1 2 3 4 5 6)
  b = '( 10 20 4 30 33)
  </code></pre>
  
  <p>Would return:</p>
  
  <pre><code>'(4 5 6)
  </code></pre>
  
  <p>I am sure that contains is working correctly, so the error must be in the code I posted. Thanks!</p>