Part 4Final Project Exploration 3
submit fredm 301-fpe3 your-files
In this exercise, you will play with at least one library provided by the PLT Scheme developers. You will have the opportunity to explore another library in each of the next two weeks.
Please choose libraries that you think you might be interested in using in your final project.
Start off at the Racket home page, http://racket-lang.org/
Then there are two places you can go for library code:
- the Documentation link, taking you here: http://http://docs.racket-lang.org//
- the PLaneT link, taking you here: http://http://planet.racket-lang.org// (this is user-contributed code)
Your job is to explore one library and write up your results. Load the library and write some code to drive it around.
For example, consider the PLT-Scheme GUI library. This linked from the main Docs page, as GUI: PLT Graphics Toolkit (see http://docs.plt-scheme.org/gui/).
Here is code to display a frame and put a button in it. Then, a lambda function is provided to handle the button-click event. This function displays the string
Button click when the button is pressed:
#lang scheme (require scheme/gui/base) ; Make a frame by instantiating the frame% class (define frame (new frame% (label "Example"))) ; Make a static text message in the frame (define msg (new message% (parent frame) (label "No events so far..."))) ; Make a button in the frame (new button% (parent frame) (label "Click Me") ; Callback procedure for a button click: (callback (lambda (button event) (send msg set-label "Button click")))) ; Show the frame by calling its show method (send frame show #t)
Honors and grad student exercise: Modify the lambda function provided as the button callback so that it displays a running count of the number of times the button is clicked. Do not use a global binding to keep track of the number of clicks; instead, do this by creating a binding (like an instance variable) in a closure of the callback lambda.
To turn in: at least 2 pages of interspersed code and narrative explaining what you did. Reminder again: please think about what you might want to work on for your final project, and choose a relevant library to work with.
REMEMBER YOU MUST GET SOMETHING WORKING! Do not just read about some APIplay with it enough so that you can make it do stuff! And show me the stuff!