Streams: Difficult Solutions
Write a function that takes in a stream, str and a finite list, lst, and determines whether or not the lst is in the stream. Assume that str is either finite or contains lst. Hint: Define a helper function.
(define (helper str lst)
(cond ((null? lst) #t)
((not (= (car lst) (car str))) #f)
(else (helper (cdr-stream str) (cdr lst)))))
(define (contains str lst)
(cond ((null? str) #f)
((and (= (car str) (car lst)) (helper str lst)) #t)
(else (contains (cdr-stream str) lst))))