Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All the code is done in Lisp The purpose of the following problem is to become familiar with the quote special form, and to learn

All the code is done in Lisp

The purpose of the following problem is to become familiar with the quote special form, and to learn to think recursively about lists and to use the list primitives of Scheme: cons, car and cdr.

a) Write a Scheme procedure is-list? that tests to see if an object is or is not a list, according to the definition of a list in the Scheme language definition. (Where is this definition? OK, I'll tell you: it's on page 25, in Section 6.3.2, which is titled "Pairs and lists". It's the second paragraph in that section.) Note: UMB Scheme already contains a built-in function list? that does this, and is written so cleverly that it works on cyclic data structures.

Please write your own procedure, however; you may assume that the argument passed to it is not cyclic. (And if you don't know what "cyclic" means in this context, don't worry about it.) Comment each line of your procedure, explaining what it does. You should explain what SHOULD happen, not what you've tried, otherwise I will not grade it.

b) Define a procedure named my-reverse. Now that you know about 'quote' you can test with more than lists of integers. my-reverse takes a list as argument and returns a list of the same elements in reverse order. (my-reverse (list 1 4 9 16 25)) will return ( 25 16 9 4 1)

Comment each line of your procedure, explaining what it does. You should explain what SHOULD happen specialy using the 'quote', not what you've tried, otherwise I will not grade it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions