For an assignment I handed in this code to remove duplicates from a stream.
(define (remove-duplicate lst)
(cond ((stream-null? lst) '())
((not (member-stream? (stream-car lst) (stream-cdr lst)))
(cons-stream (stream-car lst) (remove-duplicate (stream-cdr lst))))
(else (remove-duplicate (stream-cdr lst)))))
(define (member-stream? item x)
(cond ((stream-null? x) #f)
((eq? item (stream-car x)) x)
(else (mems item (stream-cdr x)))))
Appearantly this isn't an ideal way to do this, but I can't see why. I tested it with a stream of numbers, and it correctly removed the duplicates and returned a stream.
stream-cons, stream-car, stream-cdr and stream-null are defined in the SICP book.