reset password
Author Message
darkserith
Posts: 45
Posted 17:54 Nov 20, 2015 |

I know that we have to generate a stream for Exercise 1 (and of course to confirm results, you use stream->list on the stream)

What about the rest of the exercises?

For example, on Exercise 2, the output result of my function is a list containing the number of steps it takes for the first n numbers (starting from 1) to "collatz" to 1.

(collatz 1) takes 0 steps, (collatz 2) takes 1 steps, ect., So,

Let (num-of-steps n) be the function in question. Then,

(num-of-steps 5) outputs to the interaction pane  '(0 1 7 2 5)  ;; a list of the number of steps it takes for each of the first 5 numbers (starting from 1) to finish the collatz sequence.

Is this alright, or do you want a stream instead? I am letting the function perform the computation for the first "n numbers" because it allows me to verify my output.

 I assume that if it works for the first n numbers, then it also works for {n | n≥1, n ∈ N}.

Last edited by darkserith at 18:10 Nov 20, 2015.
rabbott
Posts: 1649
Posted 20:12 Nov 20, 2015 |

Each question other than the first defines a stream that goes on forever. So write your answer to generate a non-terminating stream for each question. To confirm your results use stream-take since stream->list won't terminate on an infinite stream.

Last edited by rabbott at 20:12 Nov 20, 2015.