Question: PLEASE solve using R5RS Scheme language. Do not solve unless you know Scheme. For the following stream related questions you may begin with (define-syntax stream-cons

PLEASE solve using R5RS Scheme language. Do not solve unless you know Scheme.

For the following stream related questions you may begin with

(define-syntax stream-cons (syntax-rules () ((stream-cons a b)(cons a (delay b))))) (define (stream-car s)(car s)) (define (stream-cdr s)(force (cdr s))) 

Write stream analogues of some familiar list processing functions:

1.(stream-first n str) -- makes a new stream of the first n items in str

2.(list->stream lis) -- makes a stream from list lis

3(stream->list str) -- reverse of above (assume str is finite)

Write stream generators to help test the above functions:

1.an infinite stream of 1's

2.an infinite stream of all odd integers

3.an infinite stream of the values of function f(n) = f(n-1) + 2f(n-2) + 3f(n-3) (given f(n)=n iff n<4).

4.Write a function combine that takes two streams and combines them using a function passed in as a third parameter. You may assume the both streams are of equal length (or infinite). (combine + (1 2 3 ...) (4 5 6 ...)) (5 7 9 ...)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!