a simple, but ugly one
;;;====================================================================================
; P08 (**) Eliminate consecutive duplicates of list elements.
; If a list contains repeated elements they should be
; replaced with a single copy of the element. The order
; of the elements should not be changed.
; Example: (compress '(a a a a b c c a a d e e e e))
; --> (A B C A D E)
;;;====================================================================================
(defun compress (mylst / 1st ans len i)
(setq 1st (car mylst)
ans (list 1st)
len (length mylst)
i 1
)
(while (< i len)
(if (equal 1st (nth i mylst))
t
(setq 1st (nth i mylst)
ans (append ans (list 1st))
)
) ; _ end of if
(setq i (1+ i))
) ; _ end of while
ans
) ; _ end of defun