CSCI 3210 Program 1 - Lisp Function Assignments - Prof. Kathleen M. Swigger, Assignments of Computer Science

Instructions and assignments for students in the csci 3210 course, focusing on lisp functions. Students are required to complete a cultural survey, write combinations of firsts and rests to extract specific values, create lisp functions for arithmetic operations, and define functions based on given conditions. Submission guidelines are also provided.

Typology: Assignments

Pre 2010

Uploaded on 08/17/2009

koofers-user-km5
koofers-user-km5 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCI 3210 Program 1
Program Assigned: September 4, 2008
Program Due: September 9, 2008 (midnight)
1. [DO NOT DO THIS[ Students need to complete Cultural Survey at :
http://zeus.csci.unt.edu/surveys.jsp
2. Write combinations of FIRSTs and RESTs (or CARs and CDRs) to pull the X out of the
following expressions.
For example (first (rest (first (rest „(a (b X) (d e)))))) => X
(bill bob jane X fred carl)
(bill (bob jane) (X fred) carl)
(bill (88 (jane (33 X fred ))) hillary)
(bill hillary chelsea (monica (ken X)))
3. Write corresponding lisp functions for the following arithmetic functions:
1 + 2 * 3
(1 + 2) * 3
2 * 4 + (6 8)
5 + (- 3 + 4)
---------------
6 + 2/5
4. Define a function average with two arguments which returns the average value.
Example: (average 3 7) returns 5, (average 1 1) returns 1
5. Define a function that returns „Waldo‟ if it is anywhere in the list.
Example: (where-is „(Ralph Sam Waldo)) returns Waldo
6. Define a function that returns:
a. the word „baby if the age of the person is less than 2
b. the word „child if the age of the person is less than 18
c. the word „adult if the age of the person is less than 120
d. the word „dead if the age of the person is more than 120
pf2

Partial preview of the text

Download CSCI 3210 Program 1 - Lisp Function Assignments - Prof. Kathleen M. Swigger and more Assignments Computer Science in PDF only on Docsity!

CSCI 3210 Program 1

Program Assigned: September 4, 2008 Program Due: September 9, 2008 (midnight)

  1. [DO NOT DO THIS[ Students need to complete Cultural Survey at : http://zeus.csci.unt.edu/surveys.jsp
  2. Write combinations of FIRSTs and RESTs (or CARs and CDRs) to pull the X out of the following expressions.

For example (first (rest (first (rest „(a (b X) (d e)))))) => X

(bill bob jane X fred carl) (bill (bob jane) (X fred) carl) (bill (88 (jane (33 X fred ))) hillary) (bill hillary chelsea (monica (ken X)))

  1. Write corresponding lisp functions for the following arithmetic functions: 1 + 2 * 3

(1 + 2) * 3

2 * 4 + (6 – 8)

5 + (- 3 + 4)

6 + 2/

  1. Define a function average with two arguments which returns the average value. Example: (average 3 7) returns 5, (average 1 1) returns 1
  2. Define a function that returns „Waldo‟ if it is anywhere in the list. Example: (where-is „(Ralph Sam Waldo)) returns Waldo
  3. Define a function that returns: a. the word „baby if the age of the person is less than 2 b. the word „child if the age of the person is less than 18 c. the word „adult if the age of the person is less than 120 d. the word „dead if the age of the person is more than 120

Submitting programs for this course:

The first three lines of any LISP program should be comments containing your name, and an identification of assignment being solved. For example:

;;; Henry M. Walker ;;;;Assignment First

Also, a comment is needed for every procedure, stating in English what that procedure is supposed to do.

  1. You will need to submit a LISTING of your program(s)
  2. Use the University‟s “project” program to turn in your programs. We will create a project name called “ first ” for you to submit your programs. The “project” program is ONLY AVAILABLE ON THE CSP machines. You will need to obtain an account number from Matt Duncan (on the fifth floor). Instructions for using “project” can be obtained by typing “man project” when you are on one of the unix systems.