Create a visual representation of how the following program is stored in LISP (D
ID: 3590799 • Letter: C
Question
Create a visual representation of how the following program is stored in LISP
(DEFUN equal_lists (lisl lis2)
(COND
((ATOM lisl) (EQ lisl lis2))
((ATOM lis2) NIL)
( (equal_lists (CAR lisl) (CAR lis2))
(equal lists (CDR lisl) (CDR lis2)))
(T NIL)
)
)
4. (10 points) Create a visual representation of how the following program is stored in LISP (DEFUN equal_lists (lisl lis2) (COND ((ATOM 1isl) (EQ lisl lis2)) ((ATOM lis2) NIL) ( (equal_iists (CAR 1isl) (CAR 1is2)) (equal lists (CDR lisl) (CDR 1is2))) (T NIL)Explanation / Answer
The following code in lisp defines a Lisp predicate function that take two lists as arguments and returns true if the two lists are equal, and NIL (false) otherwise.
(DEFUN equal_lists (lisl lis2) /. two list as argument
(COND ./ conditional
((ATOM lisl) (EQ lisl lis2))
((ATOM lis2) NIL)
( (equal_lists (CAR lisl) (CAR lis2))
(equal lists (CDR lisl) (CDR lis2)))
(T NIL) ./ return nill if not equal
)
)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.