|
Projects
Spring 2012 Older Courses Fall 2011 Spring 2011 Fall 2010 Spring 2010 Fall 2009 Spring 2009
Fall 2008
Spring 2008
Fall 2007 HOWTOs |
Home Assignments Lecture Blog Resources Project 91.301 Organization of Programming Languages Problem Set 8: Streams and Final Project ExplorationOverviewThis problem set introduces streams, which are like lists but where the cdr of a stream is a promise of delayed evaluation. Also, you will explore the PLT Scheme world and look for some interesting libraries you may wish to use in your final project. ReadingBefore doing this problem set, read the following material: ImplementationUse Module language in Dr. Scheme 4.x for this problem set. Use this streams starter code for completing the work. ProblemsFirst, some problems on the environment model and mutation. Read Section 3, 3.1, and 3.2. Problem 1: Exercise 3.1 on pp. 224. After writing and testing the code, draw the environment diagram that would result from evaluating the three statements in the exercise. Problem 2: Exercise 3.2 on pp. 224-225. After writing and testing the code, draw the environment diagram that would result from evaluating the three statements in the exercise. Problem 3: Exercise 3.3 on pp. 225, creating a password-protected bank account. Problem 4: Exercise 3.4 on pp. 225, modifying it to keep track of incorrect password accesses. Now, the streams stuff. Problem 5: Use Problem 6: Use Problem 7: Complete the following alternative definition of the integers stream: (define integers (cons-stream 1 (stream-map <??> integers))) Problem 8: Exercise 3.51 on pp. 325, examining the delayed evaluation by printing results as they are computed. Problem 9: Exercise 3.52 on pp. 325326, delayed evaluation while state is changing. Problem 10: Exercise 3.53 on pp. 330, thinking about how streams defined in terms of themselves operate. Problem 11: Exercise 3.54 on pp. 331, implementing factorial with Problem 12: Exercise 3.57 on pp. 332, understanding memo-ization as it applies to the Fibonacci computation. Final Project ExplorationIn this exercise, you will play with at least two different libraries provided by the PLT Scheme developers. Start off at the PLT Scheme home page, http://plt-scheme.org/ Then there are two places you can go for library code:
In the Documentation area, you will find detailed Getting Started guides. The More: Systems Programming with PLT Scheme walks you through building a web server in Scheme from first principles. The Continue: Web Applications in PLT Scheme goes into greater depth with this approach. If you may be interested in building a web app with Scheme, this would be a good place to start. Otherwise, have a look at the various other libraries available, including GUI and graphics libraries, networking libraries, and parsing libraries. Your job is to explore at least two libraries and write up your results. Load the libraries and write some code to drive them around. For example, if we look at the #lang scheme (require net/url) (define myurl (string->url "http://www.cs.uml.edu/")) (define myport (get-pure-port myurl)) (display-pure-port myport) Notice that This above is a trivial example; to complete this for the purposes of this assignment (if you go down the path of pulling HTTP requests), you should use the parsing libraries to parse the HTML that is returned, and then do something with the results. To turn in: 2 to 4 pages of interspersed code and narrative explaining what you did. |