Skip to content

Instantly share code, notes, and snippets.

@gavinwahl
Created September 27, 2011 05:43
Show Gist options
  • Save gavinwahl/1244417 to your computer and use it in GitHub Desktop.
Save gavinwahl/1244417 to your computer and use it in GitHub Desktop.
relation algebra
(define (zip-cons a b)
(if (null? a)
'()
(cons (cons (car a) (car b))
(zip-cons (cdr a) (cdr b)))))
(define (p c r)
(cond
((null? c) (map (lambda (x) '()) r))
((eq? (car c) (caar r))
(zip-cons
(map car r)
(p (cdr c) (map cdr r))))
(else (p c (map cdr r)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment