CSE 341, Winter 1997
D. Notkin
Major Assignment #1
Due: 1/28/97
This assignment is the primary assignment for functional
languages using ML. If you wish, you may work in pairs; both
students receive the same grade and are expected to know every
aspect of the program (even the parts one is less responsible
for). Craig will announce what he expects to be turned in, when
it should be turned in, and how it should be turned in.
Many of you may have played Mad Libs: you are prompted
for some specific parts of speech (an adjective, a past tense
verb, a name, a place, etc.) and the program fills these into
slots of a small phrase or story. In some cases, the results
are pretty hilarious. If you've never done these, you can try
running some at:
http://www.mit.edu:8001/madlib
http://www.intermotion.com/magus/java2.html
So, needless to say, you'll be writing a Mad Lib
program for your assignment. A sample input would be:
I would like to @v:something
you do@ @n1:a person's name@ and
@n2:a person's name@, both of
whom @a:an adverb@ critiqued two iterations of the @n:an object@.
They are tied for the title of
"world's greatest @no:a thing@." @n2:@, in
particular, is a real @no2:a noun@. I come from @p:a place@.
I hope you like it.
Running the program on this input (giving the inputs
after the prompts) would produce the following interaction and
then output.
- Play "game2.in";
Please enter something you
do: talk
Please enter a person's name:
Craig
Please enter a person's name:
David
Please enter an adverb: slowly
Please enter an object: ML
compiler
Please enter a thing: book
Please enter a noun: program
Please enter a place: Loew
101
I would like to talk Craig
and David, both of whom slowly critiqued two
iterations of the ML compiler.
They are tied for the title of "world's
greatest book." David,
in particular, is a real program. I come from
Loew 101. I hope you like
it.
val it = () : unit
-
So, your program has to read in the input, prompt
for the parts of speech, replace them appropriately, and print
the output. A couple of details:
Craig's solution consists of about 150 non-commented,
non-blank lines of ML code; he had under 10 functions. If you
find yourself writing way way more than this, make sure you talk
to one of us quickly to help get you back on track. In any case,
you should surely be breaking this up into manageable pieces and
writing and testing parts of it as you go. This is especially
important since you have relatively little experience with functional
programming and ML.
As a final note, I encourage you to use the mailing list to share fun input files and funny outputs that you've gotten. A special prize (worth no credit whatsoever) will be given to the person or pair who produces the funniest output of a Mad Lib; we'll take a class vote on this at some point.