2
I’m having doubts on how to do another function to delete the name and phone.
Follow the code I made:
(defun incluir (Agenda NomeTelefone)
(cond ((atom A) (cons NT 'nil))
((equal (car NT) (caar A))
(cond ((existeFone (cadr NT) (cdar A))A)
('t (cons(cons(car NT)(cons (cadr NT)(cdar A))) (cdr A)))))
('t (cons(car A)(incluir (cdr A) NT)))))
//função existeFone
(defun existeFone (NT A)
(cond ((equal NT A) A)
('t (cons (cons(car NT)(cons (cadr NT)(cdar A))) (cdr A))))
Tip: always indent your Lisp code, otherwise you will be crazy from counting parentheses... : P
– mgibsonbr
P.S. Has several parentheses missing in function
existeFone
, no? (beforeNT
, before(equal
and one closing at the end).– mgibsonbr
yes, it was missing ,I went to correct and I forgot to tidy up, thanks for correcting!!
– vitor
I had not corrected (in general, only the author of the question should tinker with his code, except for the indentation), but with his confirmation, I did it now. :)
– mgibsonbr
What is your question? What is the format of the input? What error are you having?
– hugomg
I am unable to do the exclude function.
– user26851
Do you want to delete by name, by phone or by both? I mean, if another person with that phone (but different name) is on the agenda, the function should do what? If the person has more than one phone (you seem to treat this case), the function should delete all or only what has been specified?
– user25930