CS 1102 Homework 7: Streams

Due: October 10 (Tuesday) at 11:59pm

Assignment Goals


Exercises

We have seen in class how streams may be used to represent and simulate logic circuits. Stream may also present other kinds of signals, such as as audio, video, and sensor data. These signals can be of very long duration or even infinite, making them unsuitable for lists. In this assignment, we will look at signal processing using streams.

For this assignment, you should use the stream operations in streams.scm. Note this this file uses DrScheme's built-in delay and force, rather than our own definitions.

A weather station reports the temperature (in degrees Celsius) every hour as a stream of integers.

  1. Write program fahrenheit-stream that consumes a stream of Celsius temperatures and produces a stream of Fahrenheit temperatures using the appropriate conversion formula.

  2. Write a program temperature-difference that consumes a stream of temperatures (either Celsius or Fahrenheit) and produces a stream of the difference of each temperature from the previous temperature. What should temperature-difference produce when given the-empty-stream? A stream with only a single temperature?

  3. One way to get a weighted average of the recent temperatures is to compute a smoothed output temperature stream, where
    output-temperature[N] = (input-temperature[N] + output-temperature[N-1]) / 2
    
    Write program smooth-temperature-stream that consumes a temperature stream and produces a new temperature stream in this way. Hint: Do not worry about the N's, just define the output stream in term of itself and the input.

What to Turn In

Turn in a single file hwk7.ss (or hwk7.scm) containing all code and documentation for this assignment. Make sure that both students' names are in a comment at the top of the file.


Hints and Guidelines


Back to the Assignments page