Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Define a LISP function MIN-2 with the following properties. MIN-2 takes two arguments. If those arguments have values A and B, and A and

image text in transcribed
1. Define a LISP function MIN-2 with the following properties. MIN-2 takes two arguments. If those arguments have values A and B, and A and B are numbers, then MIN-2 returns A ifASB and returns Bif A> B; but if A or B is not a number MIN-2 returns the symbol ERROR. Examples: (MIN-2 21.3 7/2) -> 7/2 (MIN-2 17.5 29) 17.5 (MIN-2 "(31)(54)) => ERROR (MIN-2 5 'APPLE)-> ERROR LISP Assignment 3: Page 1 of3 2.JExercise 4 on page 72 of Wilensky] Write a LISP function SAFE-AVG that takes 2 arguments and returns the average of those arguments if they are numbers. If one or both of the arguments is not a number, the function should return NIL Examples: (SAFE-AVG 23 47.4) 35.2 (SAFE-AVG 3 8112 SAFE-AVG (23.1) 47.3) NIL (SAFE-AVG 'ORANGE PLUM) NIL 3.IExercise 2 on page 72 of Wilenskyl Write a LISP predicate ODD-GT-MILLION that takes one argument, and which returns T if its argument is an odd integer greater than a million, but returns NIL otherwise. Hint: Make use of the predicate INTEGERP. Examples: ODD-GT-MILLION 92010231)T (ODD-GT-MILLION 17)>NIL (ODD-GT-MILLION 92010232)NIL ODD-GT-MILLION 21/5) NIL ODD-GT-MILLION (2010231)) NIL (ODD-GT-MILLION APPLE) NIL (ODD-GT-MILLION 1718671.24) NIL

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

Writing a Strong Introduction

Answered: 1 week ago