Tema Lisp - Dpto. Ciencias de la Computación e Inteligencia Artificial.
Tema Lisp - Dpto. Ciencias de la Computación e Inteligencia Artificial.
Tema Lisp - Dpto. Ciencias de la Computación e Inteligencia Artificial.
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Recursión en <strong>Lisp</strong><br />
1<br />
Ejemplo: función elimina-uno<br />
;;; (ELIMINA-UNO X L)<br />
;;; > (elimina-uno 3 ’(a b c d))<br />
;;; (A B C D)<br />
;;; > (elimina-uno ’b ’(a b c d))<br />
;;; (A C D)<br />
;;; > (elimina-uno ’b ’(a b c b d))<br />
;;; (A C B D)<br />
(<strong>de</strong>fun elimina-uno (x l)<br />
(cond ((endp l) l)<br />
((equal x (first l)) (rest l))<br />
(t (cons (first l) (elimina-uno x (rest l))))))<br />
IA-I 2003–2004 CcIa Introducción a <strong>Lisp</strong> <strong>Lisp</strong>.27