help-gnu-emacs
[Top][All Lists]
Advanced

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

All Possible Combinations


From: Nordlöw
Subject: All Possible Combinations
Date: Wed, 3 Jun 2009 02:09:56 -0700 (PDT)
User-agent: G2/1.0

Hey!

I want a function that generates all possible combinations (ordering)
of the elements in a list (or sequence if possible). Here is my
mockup:

(defun all-combinations (n)
  "Generate a listing of all the possible combinations of the
elements in the sequence N. Time-Complexity is N!"
  (let (all)
    all))

For example (all-combinations '(a b c)) should return '((a b c) (a c
b) (b a c) (b c a) (c a b) (c b a))

Has somebody written such a function, preferrably in an iterative
rather than recursive way.

Thanks in advance,
Nordlöw


reply via email to

[Prev in Thread] Current Thread [Next in Thread]