Docsity

Lisp Tutorial: Homework Assignment for Chapter 3 and 4 - Prof. Amauri Antonio Arroyo, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EEL-5840 Lisp Tutorial 1
Fall 2009 Dr. Arroyo
Class 4
1
Homework 2:
Due Tuesday September 8, 2009 in class
Be sure to follow the guidelines for Programming Assignments. Since these problems are simple,
you may skip the Statement of the Problem, Approach and Algorithm - Program Flow sections
and give an overall conclusion for the entire programming assignment. Make sure you give me a
listing of each program and at least three test cases for each. You may wish to use the "dribble"
option in the file menu of XLISP to capture the screen as you test your functions.
I. Problems 3-1, 3.3, 3.4 and 3.5 in Chapter 3 of Winston and Horn's LISP
II. Problems 4-1, 4-5 and 4-6 in Chapter 4 of Winston and Horn's LISP
XLISP-PLUS version 3.04
Portions Copyright (c) 1988, by David Betz.
Modified by Thomas Almy and others.
XLISP-STAT Release 3.52.17 (Beta).
Copyright (c) 1989-1999, by Luke Tierney.
> x
Error: The variable X is unbound.
> (setf x 1)
1
> x
1
> (+ 1 2)
3
> (+ 1 1.2)
2.2
> (/ 1 3)
0.3333333333333333
> (setf dinner steak potato bread beer onion)
Error: The variable STEAK is unbound.
Happened in: #<FSubr-PROGN: #732e8c>
> (quote x)
X
> (setf dinner (quote steak))
STEAK
> dinner
STEAK
> (setf dinner steak)
Error: The variable STEAK is unbound.
Happened in: #<Subr-TOP-LEVEL-LOOP: #75242c>
> (setf dinner 'steak)
STEAK
> (setf dinner '(steak potato bread onion beer))
(STEAK POTATO BREAD ONION BEER)
> dinner
(STEAK POTATO BREAD ONION BEER)
> (first dinner)
STEAK
> (second dinner)
POTATO
> (last dinner)
(BEER)
> (car dinner)
STEAK
pf2

Partial preview of the text

Download Lisp Tutorial: Homework Assignment for Chapter 3 and 4 - Prof. Amauri Antonio Arroyo and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EEL-5840 Lisp Tutorial 1 Fall 2009 Dr. Arroyo Class 4

1

Homework 2:

Due Tuesday September 8, 2009 in class

Be sure to follow the guidelines for Programming Assignments. Since these problems are simple,

you may skip the Statement of the Problem, Approach and Algorithm - Program Flow sections

and give an overall conclusion for the entire programming assignment. Make sure you give me a

listing of each program and at least three test cases for each. You may wish to use the "dribble"

option in the file menu of XLISP to capture the screen as you test your functions.

I. Problems 3-1, 3.3, 3.4 and 3.5 in Chapter 3 of Winston and Horn's LISP

II. Problems 4-1, 4-5 and 4-6 in Chapter 4 of Winston and Horn's LISP

XLISP-PLUS version 3. Portions Copyright (c) 1988, by David Betz. Modified by Thomas Almy and others. XLISP-STAT Release 3.52.17 (Beta). Copyright (c) 1989-1999, by Luke Tierney.

x Error: The variable X is unbound. (setf x 1) 1 x 1 (+ 1 2) 3 (+ 1 1.2)

(/ 1 3)

(setf dinner steak potato bread beer onion) Error: The variable STEAK is unbound. Happened in: #<FSubr-PROGN: #732e8c> (quote x) X (setf dinner (quote steak)) STEAK dinner STEAK (setf dinner steak) Error: The variable STEAK is unbound. Happened in: #<Subr-TOP-LEVEL-LOOP: #75242c> (setf dinner 'steak) STEAK (setf dinner '(steak potato bread onion beer)) (STEAK POTATO BREAD ONION BEER) dinner (STEAK POTATO BREAD ONION BEER) (first dinner) STEAK (second dinner) POTATO (last dinner) (BEER) (car dinner) STEAK

EEL-5840 Lisp Tutorial 1 Fall 2009 Dr. Arroyo Class 4

2

(cdr dinner) (POTATO BREAD ONION BEER) (car (cdr dinner)) POTATO (cadr dinner) POTATO dinner (STEAK POTATO BREAD ONION BEER) (cons 'cheese-fries dinner) (CHEESE-FRIES STEAK POTATO BREAD ONION BEER)