; Permutationen mit Wiederholung von drei Zahlen aus der Liste (0,...,2)
(defun permutierenM (anz bisher &aux i)
    (cond ((eql anz 0) (princ bisher))
          (t (setq i 0)
             (count 3 (permutierenM (- anz 1)(cons i bisher))
                       (setq i (+ i 1))))))

(terpri)(princ "Permutationen mit Wiederholung :")(terpri)
(permutierenM 3 ())
(terpri)
; Permutationen ohne Wiederholung, sonst wie oben
(defun in (x M)
  (cond ((null M) nil)            ;testen, ob Element bereits enthalten
        ((eq x (car M)) t)
        (t (in x (cdr M)))))

(defun permutierenO (anz bisher &aux i)
    (cond ((eql anz 0) (princ bisher))
          (t (setq i 0)
             (count 3
               (cond ((not (in i bisher))
                         (permutierenO (- anz 1)(cons i bisher))))
               (setq i (+ i 1))))))

(terpri)(princ "Permutationen ohne Wiederholung :")(terpri)
(permutierenO 3 ())
(terpri)