From ... From: Erik Naggum Subject: Re: Q: tail-recursive procedure to generate all permutations of a list Date: 2000/10/05 Message-ID: <3179726196411119@naggum.net>#1/1 X-Deja-AN: 677811576 References: <8qojjq$lr5$1@nnrp1.deja.com> <3179671668484915@naggum.net> <8rgqhf$8ql@borg.cs.waikato.ac.nz> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 970738889 4238 195.0.192.66 (5 Oct 2000 09:41:29 GMT) Organization: Naggum Software; vox: +47 800 35477; gsm: +47 93 256 360; fax: +47 93 270 868; http://naggum.no; http://naggum.net User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Mime-Version: 1.0 NNTP-Posting-Date: 5 Oct 2000 09:41:29 GMT Newsgroups: comp.lang.lisp * Bernhard Pfahringer | Most likely this will work in all implementations, but it is not | guaranteed to do so. You would need to test (equal rotation list), | as nbutlast *may* modify its argument, but it does not have to. The argument shouldn't be modified when it's too short, which is the case I find covered by that "may", not some broken implementation that fails to get the whole point of the nbutlast operator. So if it doesn't, complain vociferously to your vendor, and follow my advice to optimize this by doing your own cons cell hacking. | Also memory-consumption could be reduced by replacing | (copy-list list) simply with list, thereby allowing permutations | to share common suffixes. They would share common suffixes, allright, but those suffixes would then continue to change as the whole point of this implementation is to rotate the elements of the list in place by cons cell hacking. (Please try out your suggestions before posting them. It is quite inconsiderate towards your readers to want all of them to try what you suggest only to find that it doesn't work when you could have avoided giving false advice by trying it out yourself. There's also an insult to the intelligence of the writer of the first code to assume that doing a copy-list had no purpose or even good reason. However, I'm not thrilled with the memory consumption myself, so any working optimization is definitely welcome.) | And of course I had to do a slightly modified version as well :-) Meta-permutation? :) #:Erik -- If this is not what you expected, please alter your expectations.