[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Will Fitzgerald <fitzgerald@xxxxxxxxxxxx>



Michael Sperber <sperber@xxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
>>>>>> "Will" == Will Fitzgerald <fitzgerald@xxxxxxxxxxxx> writes:
>
>Will> May I suggest the following addition to the SRFI-1 list library,
>Will> Common Lisp's LDIFF:
>
>Will> I think a reasonable definition is:
>Will> [...]
>[...]
>Could you suggest possible uses for this procedure?

The following gem is by Duncan Smith...

(defun permute (ls)
  (if (null ls)
    nil
    (if (null (cdr ls))
      (list ls)
      (mapcon
       #'(lambda (x)
           (mapcar
            #'(lambda (y)
                (cons (car x) y))
            (permute (nconc (ldiff ls x) (cdr x)))))
       ls))))

e