Code: Select all
(defun dotted-pair(lst) ; lst:= a list
(labels ((dp (i lst)
(if (or (eq lst nil) (not (eq (mod (list-length lst) 2) 0)))
nil
(append (list (cons (first lst) i)) (dp (1+ i)(rest lst))))))
(dp 1 lst)))
Code: Select all
(dotted-pair ()) ; => nil
(dotted-pair '(a b c) ; => nil
(dotted-pair '(v x y z) ; => ((V.1))