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

Will Fitzgerald <fitzgerald@xxxxxxxxxxxx>

This page is part of the web mail archives of SRFI 1 from before July 7th, 2015. The new archives for SRFI 1 contain all messages, not just those from before July 7th, 2015.



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