Difference between revisions of "Streams Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
(Created page with "[https://www.coursera.org/learn/programming-languages-part-b/programming/VsOW3/homework-4-instructions Instructions] [https://www.coursera.org/learn/programming-languages-par...")
 
Line 2: Line 2:
  
 
[https://www.coursera.org/learn/programming-languages-part-b/supplement/YqQwn/notes-and-tips-for-section-5 Notes and Tips]
 
[https://www.coursera.org/learn/programming-languages-part-b/supplement/YqQwn/notes-and-tips-for-section-5 Notes and Tips]
 +
 +
=Provided Code for Graphical Output=
 +
The code at the top of <code>hw4combined_tests_with_graphics.rkt</code> uses a graphics library to provide a simple,
 +
entertaining (?) outlet for your streams. You need not understand this code (though it is not complicated)
 +
or even use it, but it may make the homework more fun. This is how you use it:
 +
 +
* <code>(open-window)</code> returns a graphics window you can pass as the first argument to place-repeatedly.
 +
* <code>(place-repeatedly window pause stream n)</code> uses the first n values produced by stream. Each
 +
stream element must be a pair where the first value is an integer between 0 and 5 inclusive and the
 +
second value is a string that is the name of an image file (e.g., .jpg). (Sample image files that will work
 +
well are available on the course website. Put them in the same directory as your code.) Every pause
 +
seconds (where pause is a decimal, i.e., floating-point, number), the next stream value is retrieved,
 +
the corresponding image file is opened, and it is placed in the window using the number in the pair to
 +
choose its position in a 2x3 grid as follows:
 +
 +
{| class="wikitable" style="margin: auto;"
 +
|0
 +
|1
 +
|2
 +
|-
 +
|3
 +
|4
 +
|5
 +
|}
 +
 +
Two of the provided tests demonstrate how to use <code>place-repeatedly</code>. The provided tests require you to
 +
complete several of the problems, of course. We hope these tests’ expected (visual) behavior is not difficult
 +
for you to figure out.

Revision as of 09:26, 23 October 2020

Instructions

Notes and Tips

Provided Code for Graphical Output

The code at the top of hw4combined_tests_with_graphics.rkt uses a graphics library to provide a simple, entertaining (?) outlet for your streams. You need not understand this code (though it is not complicated) or even use it, but it may make the homework more fun. This is how you use it:

  • (open-window) returns a graphics window you can pass as the first argument to place-repeatedly.
  • (place-repeatedly window pause stream n) uses the first n values produced by stream. Each

stream element must be a pair where the first value is an integer between 0 and 5 inclusive and the second value is a string that is the name of an image file (e.g., .jpg). (Sample image files that will work well are available on the course website. Put them in the same directory as your code.) Every pause seconds (where pause is a decimal, i.e., floating-point, number), the next stream value is retrieved, the corresponding image file is opened, and it is placed in the window using the number in the pair to choose its position in a 2x3 grid as follows:

0 1 2
3 4 5

Two of the provided tests demonstrate how to use place-repeatedly. The provided tests require you to complete several of the problems, of course. We hope these tests’ expected (visual) behavior is not difficult for you to figure out.