CSE 341 -- Programming Languages

Winter 2000

Department of Computer Science and Engineering, University of Washington

Steve Tanimoto (instructor) and Jeremy Baer (teaching assistant).

Assignment L2

Version 1.02 of October 12.  Subject to change.

Functional Programming on the Web 

Due date and time: Monday, October 16, 2000 at 5:30 PM (Submit your assignment electronically by filling out an online submission form.). (Fill out the milestone form by 5:00 PM Tuesday, October 10.

 

Title: Functional Programming on the Web.

Purposes:  Explore the use of Lisp to manipulate language expressions (either English text or logical formulas) and perform limited reasoning with them in a World-Wide Web context.

Instructions:  Read the information about creating web-based agents in Lisp.  Choose one of the following two options:

Option 1. Formating Lisp expressions for Web Browsers:
Part 1A. Write a Lisp program called layout-formula.lsp  that translates a mathematical formula given in Lisp into an HTML description using TABLEs so that a web browser displays the formula as a 2-dimensional mathematical formula.  Here's a sample executable with an HTML page for entering data.  If you view the HTML source of the output page, you should note the use of nested <TABLE> formatting.
Part 1B. Write a Lisp program called web-pretty-print.lsp  that accepts a Lisp program (one or more S-expressions) in a text area of a browser and produces a web page in which the program is nicely indented according to it level of parenthesization and the lengths of lines.
 

Option 2. Interactive Sequence Predictor
Part 2A. Write a Lisp program called  predictor1.lsp  that carries on a limited kind of dialog with the user over the web, such that the user can successively enter numbers and the program will, after each number, respond with its simplest description of the sequence so far, together with the value it predicts as next in the sequence.  This program should make use of some form of session management, as described in Appendix A of the Lisp course notes.  In this part, your program should manage the dialog and handle arithmetic sequences such as  1, 4, 7, 10, . . .
Part 2B.  Create predictor2.lsp by extending predictor1.lsp to handle a greater variety of sequences, namely the recursively defined class of "recognizable sequences" defined as follows:
 [1]. Any arithmetic sequence is a recognizable sequence. Example: 2, 4.5, 7, 9.5, 12, ...
 [2]. Any geometric sequence is a recognizable sequence. Example: 1, 2, 4, 8, 16, ...
 [3]. If a0, a1, a2, ... and b0, b1, b2, ... are two recognizable sequences then the interleaved sequence a0, b0, a1, b1, a2, b2, ... is a recognizable sequence. Example: 2, 1, 4.5, 2, 7, 4, 9.5, 8, 12, 16, ...

Since these "recognizable sequences" can get fairly complicated, your program should look for simple descriptions first, and then it should test
more and more complicated hypotheses.  Using a global parameter in your program, set a reasonable limit to the depth of the search, so
that the predictor can give up before consuming too many of the web server's processing cycles.

You are encouraged to work in groups of 2 on this assignment.  One partner should maintain the files in his or her directory on Cubist and should file the submission forms electronically.  The other partner may keep his or her own copy of the files.  However, the grade for the team will be based upon the materials submitted by the first partner submitting for the pair.