title: Count number of pairs in Scheme
body: <p>I have an assignment, where I need to count the number of pairs in the input.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>(define x 0)
  
  (define number-of-pairs
    (lambda (v)
      (if (pair? v)
          (+ x 1)
          (+ x 0))))
  </code></pre>
  
  <p>And then I use it as follows:</p>
  
  <pre><code>(number-of-pairs (cons (cons 'a 'b) 'c))
  </code></pre>
  
  <p>Here it should produce 2, but it instead produces 1, as it only go through the function once.
  If I try</p>
  
  <pre><code>(number-of-pairs 10)
  </code></pre>
  
  <p>it produces 0, as it should because there are no pairs.</p>