kbushnel.sdf-us.org/contact.html Week 3 kbushnel.sdf-us.org/contact.html Week 3 comments, questions Course: Introduction to Lisp on sdf Instructor: jgw Book: "COMMON LISP: A Gentle Introduction to Symbolic Computation" by David S. Touretzky copyright 1990 ANSWERS to the Questions =============================================== 6.10 (defun PALINDROMEP (x) (equal x (reverse x))) ex: (PALINDROMEP '(a b c b a)) ------------- 6.22 (setf A '(SOAP WATER)) (union A '(no soap radio))=> (soap radio) (intersection A (reverse A)) => (water soap) (set-difference A '(stop for water))=>(stop for) (set-difference A A) => NIL (member 'soap A) => (SOAP WATER) (member 'water A) => (WATER) (member 'washclothe A) => NIL ------------------------------ 6.29 length ----------------------------- 6.34 (setf ATLAS ((pennsylvania pittsubrgh johnstown) (new-jersey newark princeton trenton) (ohio columbus))) (defun GET-CITY (x) (rest (assoc x ATLAS)) ================================================ QUESTIONS about reading material ============================================ pg 164 example shows: (defun add-to-end (x e) "Adds element E to the end of list X." (append x (list e))) (add-to-end '(a b c) 'd) => (A B C D) So I just wanted to make sure: since 'e', defined within defun inputs (x e), makes 'd', of (add-to-end '(a b c) 'd), a list? Otherwise if 'd' was just appended it wouldn't be a list. Or does 'd' become a list when it's declared as list in (append x (list e))) as part of the 'defun' function? --------------------- pg 164 example shows > (cons '(here today) '(gone tomorrow)) ((HERE TODAY) GONE TOMORROW) I'm still not sure where the left parenthesis went that was before 'gone' i.e '(gone. ------------------------- also on pg 164 example shows > (append '(here today) '(gone tomorrow)) (HERE TODAY GONE TOMORROW) Does 'GONE TOMORROW' have a CAR and a CDR? That's probably obvious judging by figure 6.1. ----------------------- pg 182 Example showed (quality 'red) => color where element queried is (red . color). Why doesn't (quality 'red) => . color, with the period, since the table entry is (red . color)? ===================================================== COMMENTS ============================================ Notes; Interesting the Lisp adds the space to a list. Example shown: (append '(friends romans) '(and countrymen)) No space between 'romans' and 'and' in the append function but it's there in the output: (friends romans and coutrymen) I wonder how this will be used? ------------------------------- "REMOVE is a non destructive function. ... The result returned by REMOVE is a new list." pg 168 [That's probably significant.] ----------------------------------- Okay! I tried to do it. I tried to think in parenthesis, which appears to be the most important concept of the 'Introductory' Tourtezky instructional method. However it still eludes me to an extent. A dedicated student should apply more focus on CAR, CDR, and Eval Notation. Fianally! Got Clisp and ECL installed on FreeBSD. MegaPOP dialup service didn't update zone files.