Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3.[Exercise 2 on p. 72 of Wilensky] Write a LISP predicate ODD-GT-MILLION that takes one argument, and which returns T if its argument is an
3.[Exercise 2 on p. 72 of Wilensky] 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 illion, but returns NIL otherwise. Hint: Make use of the predicate INTEGERP. Examples: (ODD-GT-MILLION 920 10231)=> T (ODD-GT-MILLION 17)=> NIL (ODD-GT-MILLION 920 10232)=> NIL (ODD-GT-MILLION 21/5)-NIL (ODD-GT-MILLION ,(2010231)) => NIL (ODD-GT-MILLION 'APPLE) => NIL (ODD-GT-MILLION 1718671.24)=> NIL 4.[Exercise 3 on p. 72 of Wilensky] Re-read the discussion of MEMBER in sec. 6.6 of Touretzky or on p. 51 of Winston & Horn. Then write a LISP predicate MULTIPLE-MEMBER that takes two arguments and behaves as follows: If the first argument is a symbol or number and the second is a list, then MULTIPLE-MEMBER returns a true value if the first argument occurs at least twice in the second argument, and returns NIL otherwise. Examples: (MULTIPLE-MEMBER 'A '(B A B B A C A D)) => (A C A D) (MULTIPLE-MEMBER 'A '(B A B B C C A D)) => (A D) (MULTIPLE-MEMBER 'A '(B A B B C D)) => NIL [Notice that the behavior of MULTIPLE-MEMBER is unspecified in cases where the first argument is not a symbol or number, and in cases where the second argument is not a list. In other words, your definition may return any value or produce an evaluation error in such cases.] 3.[Exercise 2 on p. 72 of Wilensky] 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 illion, but returns NIL otherwise. Hint: Make use of the predicate INTEGERP. Examples: (ODD-GT-MILLION 920 10231)=> T (ODD-GT-MILLION 17)=> NIL (ODD-GT-MILLION 920 10232)=> NIL (ODD-GT-MILLION 21/5)-NIL (ODD-GT-MILLION ,(2010231)) => NIL (ODD-GT-MILLION 'APPLE) => NIL (ODD-GT-MILLION 1718671.24)=> NIL 4.[Exercise 3 on p. 72 of Wilensky] Re-read the discussion of MEMBER in sec. 6.6 of Touretzky or on p. 51 of Winston & Horn. Then write a LISP predicate MULTIPLE-MEMBER that takes two arguments and behaves as follows: If the first argument is a symbol or number and the second is a list, then MULTIPLE-MEMBER returns a true value if the first argument occurs at least twice in the second argument, and returns NIL otherwise. Examples: (MULTIPLE-MEMBER 'A '(B A B B A C A D)) => (A C A D) (MULTIPLE-MEMBER 'A '(B A B B C C A D)) => (A D) (MULTIPLE-MEMBER 'A '(B A B B C D)) => NIL [Notice that the behavior of MULTIPLE-MEMBER is unspecified in cases where the first argument is not a symbol or number, and in cases where the second argument is not a list. In other words, your definition may return any value or produce an evaluation error in such cases.]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started