Question: Code and run the following functions in LISP . Each question carries 5 points. Recursion must be used only when stated in the question. Please
Code and run the following functions in LISP. Each question carries 5 points. Recursion must be used only when stated in the question. Please include sample demo snapshots of executing these codes.

1. Construct a function WEIGHT-OF-PURCHASE that computes the sum of the weights from a "shopping list". The shopping list has two sublists with the weight of the item as the second element. Examples WEIGHT-OF-P 1500 WEIGHT-OF-PURCHASE((FLOUR 500 GRAMS) (CHEESE 100 GRAMS)e 600 ((MILK 1000 GRAMS) (SUGAR 500 GRAMS))) 2. Define a function INSERT-BEHIND, which, in contrast to CONS, inserts a LISP expression into the back of a list instead of the front. Examples (INSERT-BEHIND FOOTBALL) (LLIKE)e (I LIKE (FOOTBALL)) INSERT-BEHIND 'DIFFICULT (LISP IS NOT) (LISP IS NOT DIFFICULT) 3. Write a predicate SAFE-LESSP that has two arguments and firstly makes certain that it is dealing with two numbers. If the irst number is smaller than the second, T should be returned, otherwise return NIL. 4. Write a function WHAT-IS-IT that accepts an argument and returns what it is. In case of a number return NUMBER, in case of a symbol return S-ATOM, and in case of a list return LIST. If it is none of these, return DO-NOT-KNOW Examples (WHAT-IS-IT "THIS IS A STRING") DO-NOT-KNOW WHAT-IS-IT 2) NUMBER 5. Define a recursive function ALL-SAME-AS-ELEMENT that has two arguments, an atom and a list. ALL-SAME-AS ELEMENT should test whether all the elements in the list are the same as the atom. Should this be the case, the value returned should be T, otherwise NIL. Examples ALL-SAME-AS-ELEMENT 'X(XXX)) ALL-SAME-AS-ELEMENT 'YXY X) NIL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
