SICP Practice

Practice 3.67

(define (all-pairs s1 s2)
  (cons-stream (list (stream-car s1) (stream-car s2))
               (interleave
                 (interleave
                           (stream-map (lambda (x) (list (stream-car s1) x))
                                       (stream-cdr s2))
                           (all-pairs (stream-cdr s1) (stream-cdr s2)))
                 (stream-map (lambda (x) (list (stream-car s2) x))
                             (stream-cdr s1)))))