Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE LISP TO DO SOME PROGRAM 1.A triangular number or triangle number counts the objects that can form an equilateral triangle One can define a

USE LISP TO DO SOME PROGRAM

1.A triangular number or triangle number counts the objects that can form an equilateral triangle

One can define a function to compute the triangular number as:

T(n) = 1

if n = 1

T(n) = n + T(n-1)

if n > 1

Create a Lips function that calculate the triangular number, e.g., (defun triangular-number (x))

To test your Lisp program, calculate (triangular-number 5) & (triangular-number 6)

2.Define a new function, called ismember, that returns TRUE if the atom is a member of a list, or FALSE otherwise, i.e.,: (defun ismember (atom list))

For instance:

(ismember a (1 2 3)) would return false

(ismember 1 (1 2 3) would return true

To quickly implement ismember you can take advantage of Lisp membership functions. As you know, list have several functions to handle lists. For instance, member, member-if, and member-if-not each search list for item or for a top-level element that satisfies the test. The argument to the predicate function is an element of list. If some element satisfies the test, the tail of list beginning with this element is returned; otherwise nil is returned.

3. Define a lisp function that calculates the size of a list called

(defun recursive-list-length (L) ...)

where (recursive-list-length '(1 2 3 5 7 11 13 17 19)) would be equal to 9

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_2

Step: 3

blur-text-image_3

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

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions