Homework # 15

Note that this is actually a programming assignment – not just a homework!

 

1.  Read chapters 15 and 6 and look at the slides

 

2a.   Write a LISP program (function) that determines whether the object you give it is a palindrome.

Be sure to document your program including a description of examples of what a palindrome for different things should look like.

 

2b. Write a LISP program (function) that determines whether an  integer is divisible by 13.

 

2c.   LISP’s built-in function REVERSE performs as shown in the box below.  Without using the built-in function, write two functions that reverse lists in two different ways.

REVERSE1 should  produce the same results as REVERSE does

REVERSE2 should produce a list in which each of the elements’ positions is reversed.  The desired result of REVERSE2  is shown

below.

> (REVERSE2  '( (a b) c (d (e f))))

(f e d c b a)

 

 > (reverse '(a b d))

(d b a)

> (reverse  '( (a b) c (d (e f))))

((d (e f)) c (a b))

 

 

Required:

standard heading

standard descriptions

comments explaining how LISP language works (what the functions you use do)

 

Deliverables: 

 

Notes: 

To trace a Lisp function at the prompt type

>  (trace functioName)

 

To have the screen output also appear in a file, at the prompt type

> (dribble “destinationPathAndFileName”)

If you don’t give the complete path, it will end up the whatever directory you are running your version of Lisp from

 

 

When you want to stop having the output go to the file, at the prompt type

> (dribble)

i.e.  dribble without a destination turns it off