Skip to content

Instantly share code, notes, and snippets.

@mmitou
Created February 25, 2015 06:01
Show Gist options
  • Select an option

  • Save mmitou/ab7ce93c875b77c2da9d to your computer and use it in GitHub Desktop.

Select an option

Save mmitou/ab7ce93c875b77c2da9d to your computer and use it in GitHub Desktop.
(define (rember x xs)
(cond
((null? xs) '())
((eq? x (car xs)) (rember x (cdr xs)))
(else (cons (car xs) (rember x (cdr xs))))))
(define (multirember&co a lat col)
(cond
((null? lat) (col '() '()))
((eq? a (car lat))
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col newlat (cons (car lat) seen)))))
(else
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col (cons (car lat) newlat) seen))))))
(multirember&co 3 '(1 2 3 4 5 6) (lambda (newlat seen)
(begin
(display newlat)
(newline)
(display seen))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment