From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Nordl=F6w?= Newsgroups: gmane.emacs.help Subject: All Possible Combinations Date: Wed, 3 Jun 2009 02:09:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <778c22e3-3233-4cec-899e-c9f77208155a@z14g2000yqa.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1244022339 7387 80.91.229.12 (3 Jun 2009 09:45:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Jun 2009 09:45:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 03 11:45:37 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MBn2O-0000KS-Hi for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Jun 2009 11:45:36 +0200 Original-Received: from localhost ([127.0.0.1]:53235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MBn2N-0003z0-UG for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Jun 2009 05:45:35 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!z14g2000yqa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 20 Original-NNTP-Posting-Host: 81.170.250.228 Original-X-Trace: posting.google.com 1244020196 12740 127.0.0.1 (3 Jun 2009 09:09:56 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 3 Jun 2009 09:09:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z14g2000yqa.googlegroups.com; posting-host=81.170.250.228; posting-account=ytJKAgoAAAA1tg4ScoRszebXiIldA5vg User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1pre) Gecko/20090526 Ubuntu/9.04 (jaunty) Shiretoko/3.5pre, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:169683 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64913 Archived-At: 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=F6w