2015/10/26

SICP 問題 2.62

(define (union-set s t)
  (cond ((null? s) t)
        ((null? t) s)
        ((= (car s) (car t))
         (cons (car s)
               (union-set (cdr s) (cdr t))))
        ((< (car s) (car t))
         (cons (car s)
               (union-set (cdr s) t)))
        ((< (car t) (car s))
         (cons (car t)
               (union-set s (cdr t))))))

© 2022 wat-aro