scheme and prolog

a. Define a Prolog predicate with three lists as arguments that returns True if the third list is obtained from the first list by eliminating those elements that appear in the second list.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Example: ??         diff([2,5,4,9,1],[6,2,0,?3,9],R). R=[5,4,1].

Hint: you may use the member predicate.

b . in  scheme ( pad x ) returns the list in which each zero element is replaced by the previous non – zero element in the list . Any leading zeros will remain unchanged .

Example : ( pad ‘(0 -1 0 4 0 0 -2)) returns the list (0 – 1 – 1 4 4 4 – 2))

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

c . in  scheme  ( aprog ) returns True if list is an arithmetic progression and False otherwise . Recall that an arithmetic progression is a sequence in which each element ( except the first ) can be obtained from the previous one by adding a fixed value called the common difference .

Example : ( aprog ( 2 5 8 11 14 17 ) ) evaluates to True ( the common difference here is 3 ) .

d . Consider the function fun defined as follows: in  scheme

define (fun 1) (if (null? I) I                                                                                                                                                                                             (cons (car 1) (map (lambda (x) (+ (car l) x)) (fun (cdr !))))))                                                                                  Give the value of the expression (fun (7 2 4)) and explain how it is computed (trace the code for the given input).

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER