unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* All Possible Combinations
@ 2009-06-03  9:09 Nordlöw
  2009-06-03  9:53 ` Pascal J. Bourguignon
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Nordlöw @ 2009-06-03  9:09 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-05 15:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-03  9:09 All Possible Combinations Nordlöw
2009-06-03  9:53 ` Pascal J. Bourguignon
2009-06-03 13:36   ` B. T. Raven
2009-06-03  9:55 ` Lennart Borgman
2009-06-03 18:50 ` Marc Tfardy
2009-06-04  6:08   ` Nordlöw
2009-06-04  7:20     ` Marc Tfardy
2009-06-04 16:25       ` B. T. Raven
2009-06-05 15:49       ` Thierry Volpiatto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).