P11: P10で(1 A)となるようなところは Aにする。

;;;
;; P11 (*) Modified run-length encoding.
;;  Modify the result of problem P10 in such a way that if an element 
;; has no duplicates it is simply copied into the result list. 
;; Only elements with duplicates are transferred as (N E) lists.
;; Example:
;; * (encode-modified '(a a a a b c c a a d e e e e))
;; ((4 A) B (2 C) (2 A) D (4 E))
(defun encode-modified (lis)
    (mapcar (lambda (x)
	      (if (= (first x) 1)
		  (second x)
		x))
	    (encode lis)))

(encode-modified '(a a a a b c c  a a d e e e e))
;; => ((4 A) B (2 C) (2 A) D (4 E))
(encode-modified '(nil nil nil nil nil t t t t t))
;; => ((5 NIL) (5 T))
(encode-modified '(nil t t t t t nil))
;; => (NIL (5 T) NIL)
(encode-modified nil)
;; => NIL