Final HW Assignment
The goal of this problem set is to practice the design of generative
recursive functions, accumulator-style functions, and to design
distributed programs and evaluators. Start
early, these are some tough problems.
Using the chat program you developed in
in lab
and the evaluator we developed
in class,
write RacketBot: a program that poses as a chat
user. When RacketBot is sent a message that is an expression, it
should evaluate it and reply with its result.
You must first implement excercise 7 from lab, which adds private
messages. When RacketBot receives a private message addressed to it,
it should try to read the message as an s-expression and evaluate it.
If the s-expression is a valid program, it responds with a private
message to the original sender with the result of evaluation. If the
message is not a valid program, RacketBot should respond that it did
not understand.
The string->sexp function will come in handy, which given
a string produces the corresponding s-expression, if there is one, and
false otherwise. To add this function, save
the string-to-sexp.rkt file
to your homework directory and include (require
"string-to-sexp.rkt") at the top of your program.
As an extra bonus worth no points: can you think of a message that you
could send RacketBot that would make it totally unresponsive so that it
never responds to your message, or anybody elses?
Note that RacketBot, if designed properly, should never crash; but that
doesn't mean it can't become very, very busy.