title: Ordered streams of pairs - Scheme
body: <p>I am trying to order streams of pairs according to the weight of the pairs - the sum of the two numbers in the pair.  (I'm not excluding duplicates.)  My code doesn't seem to be working</p>
  
  <pre><code>(define (merge-weighted s1 s2 weight)
    (let ((h1 (stream-car s1))
          (h2 (stream-car s2)))
      (if ((weight h1) &lt; (weight h2))
          (cons-stream h1 (merge-weighted (stream-cdr s1) s2 weight))
          (cons-stream h2 (merge-weighted new1 (stream-cdr s2) weight)))))
  </code></pre>
  
  <p>when calling merge-weighted on a stream of integers (s1) with another stream of integers (s2) and using the following weight1:</p>
  
  <pre><code>(define (weight1 pair)
    (+ (car pair) (cdr pair)))
  </code></pre>