Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Subject: Principle of programming language please send me the accurate answer of all please... thanks 5. Define a LISP function MONTH->INTEGER which takes as argument

Subject: Principle of programming language

please send me the accurate answer of all please... thanks

5. Define a LISP function MONTH->INTEGER which takes as argument a symbol that should be the name of a month, and which returns the number of the month. For example, (MONTH->INTEGER 'MARCH) => 3 and (MONTH->INTEGER 'JUNE) => 6. If the argument is not a symbol that is the name of a month, the function should return the symbol ERROR. E.g., (MONTH->INTEGER 'C) => ERROR, (MONTH->INTEGER 7) => ERROR, (MONTH->INTEGER 'QUOTE) =>ERROR, and (MONTH->INTEGER '(MAY)) =>ERROR.

6. Define a LISP function SCORE->GRADE which takes a single argument, s, and returns a symbol according to the following scheme: s 90 A 73 s < 77 C+ 87 s < 90 A 70 s < 73 C 83 s < 87 B+ 60 s < 70 D 80 s < 83 B s < 60 F 77 s < 80 B If the argument s is not a number then the function should return NIL. Examples: (SCORE->GRADE 86.3) => B+ (SCORE->GRADE 106) => A (SCORE->GRADE 10.1) => F (SCORE->GRADE 59.9) => F (SCORE->GRADE 83) => B+ (SCORE->GRADE 74) => C+ (SCORE->GRADE 67) => D (SCORE->GRADE 87.0) => A (SCORE->GRADE '(86.3)) => NIL (SCORE->GRADE 'DOG) => NIL Solve problems 7, 8, and 9 without using COND, IF, WHEN, UNLESS, or CASE.

7. Define a LISP function GT with the following properties. GT takes two arguments. It returns T if both arguments are numbers and the first argument is strictly greater than the second. In all other cases GT returns NIL.

8. Define a LISP function SAME-PARITY with the following properties. SAME-PARITY takes two arguments. It returns T if both arguments are even integers or if both arguments are odd integers. In all other cases SAME-PARITY returns NIL. Examples: (SAME-PARITY 0 1) => NIL (SAME-PARITY 3 9) => T (SAME-PARITY 30 90) => T (SAME-PARITY 'A 'A) => NIL (SAME-PARITY 4.1 3.7) => NIL LISP Assignment 3: Page 3 of 3

9. Define a LISP function SAFE-DIV with the following properties. SAFE-DIV takes two arguments. If both arguments are numbers and the second does not satisfy ZEROP, then the function returns the result of dividing the first argument by the second. In all other cases it returns NIL. Examples: (SAFE-DIV 6 4) => 3/2 (SAFE-DIV 6.0 4) => 1.5 (SAFE-DIV 6 0) => NIL (SAFE-DIV 6 0.0) => NIL (SAFE-DIV '(6) 4) => NIL (SAFE-DIV 6 T) => 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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions