In LISP, code the function ( printWOP lis ) which is passed a list. It prints li
ID: 3602365 • Letter: I
Question
In LISP, code the function (printWOP lis) which is passed a list. It prints lis without surrounding parentheses on one line.
It first does a (terpri) to cause printing at the beginning of the line.
If the lis is an atom, simply PRINC it and do not do the next step.
For each entry in the list:
use PRINC to print the item
use PRINC to print a space (PRINC " ")
Finally, it does another (terpri).
Functionally, printWOP returns T.
Hint: break this into two functions. The step where we go through the list should probably be done by another function.
> (printWOP '(A B D))
A B D
T
> (printWOP '(A (B D) E F) )
A (B D) E F
T
> (printWOP NIL)
NIL
T
> (printWOP 'A)
A
T
Explanation / Answer
(defun person-at (loc pers per-locs)
(labels ((at-loc-p (pers)
(eq (cadr (assoc pers per-locs)) loc)))
(remove-if-not #'at-loc-p pers)))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.