Skip to content

Instantly share code, notes, and snippets.

@yakreved
Created August 29, 2013 12:23
Show Gist options
  • Save yakreved/6377394 to your computer and use it in GitHub Desktop.
Save yakreved/6377394 to your computer and use it in GitHub Desktop.
sicp 2.62
(define a '(1 2 4 6))
(define b '(3 4 5 6 7 8))
(define (union-set x y)
(cond
((null? x) y)
((null? y) x)
((= (car x) (car y))
(cons (car x) (union-set (cdr x) (cdr y))))
((< (car x) (car y))
(cons (car x) (union-set (cdr x) y)))
(else (cons (car y) (union-set x (cdr y))))))
(union-set a b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment