I was hoping to get some help with a couple of problems I am working on.
On both problems I am working with a list of form:
(setf jane '((jane (address
(number 1201)
(street main)
(city san-antonio)
(state texas)
(zip 75438))
(parents
(father pete)
(mother sue))
(children bob)
(name jane)
(weight 120))))
First, I need to define a function that receives an association list of the form above and returns the following list:
output --> (jane father is pete mother is sue)
I have not defined a function yet, but I am able to produce the above output, without the "is" string, with the follwing code:
(defun info () (append (first (list (first (rest (second (rest (first jane)))))
(second (rest (second (rest (first jane)))))))
(second (list (first (rest (second (rest (first jane)))))
(second (rest (second (rest (first jane)))))))))
(append (rest (fifth (first jane)))
(info)) The above code outputs (JANE FATHER PETE MOTHER SUE)
My question is, how do I get the "is" string in (jane father
is pete mother
is sue) outputed?
For my second problem, I need to define a function that receives a key and an association list of the form above and returns the list in which key is the first member of.
I can, for example, produce the value of children, which is bob, with the follwing code:
(second (assoc 'children (rest (first jane))))
How come when I define a function with the code below, I get NIL when searching for the value of children?
(defun search-for (key in-list)
(second (assoc 'key (rest (first in-list))))) Searching with:
(search-for 'children jane)
Any help would be greatly appreciated.