Dana Vrajitoru
C311 Programming Languages
Homework 2
Due Date: Thursday, September 11, 2008.
Note. The results of the entire exercise should be sent in
one file with the extension .el as an attachment to an email.
Ex. 1 Write a Lisp program and do the following:
- Declare at least 3 variables, one of which should contain a
description.
- Assign numerical values to the three variables.
- Show an example (as many expressions as you want) of using the
following mathematical functions, involving the variables you
declared: expt, random, abs, cos, truncate.
- Invoke the help on one of the functions listed above and copy it
into the program, then comment it out. Hint: when editing a file with
the extension .el, a menu option called Emacs-Lisp should appear. You
can select the entire region you want to comment out and then use a
command in this menu to comment it out.
- Turn the interactive mode on and evaluate your expressions to make
sure they are correct.
Ex. 2 Implement the following functions in the same file,
complete with short descriptions:
- A function list-sum that returns the sum of the elements of
a list, assuming that they are all numbers.
- A function is-in-list that takes two parameters, the first
being a list and the second a value, and returns true (t) if the value
is in the list and false (nil) if not. Use the function equal to
test for equality of two values.
Evaluate both of these functions and show a few examples of testing
them.
Send the file by email as an attachment. Note: anything but the Lisp
expressions and the results of their evaluation should be commented
out in the file uning the ";". Make sure that there is a comment at
the top with your name and homework number.