(set 'L '()) (dolist (s (explode "aaaabbbcca")) (if (!= (ref-all s L) '((0 0))) (push (list s 1) L) (inc (L 0 1)))) (print (reverse L))