All possible combinations algorithm

Michael Halcrow mike at
Thu Jun 16 11:55:26 MDT 2005

On Tue, Jun 14, 2005 at 11:03:29PM -0600, Dan Wilson wrote:
> PS. This is for PHP, so if you have code examples, that would be
> even better.

For those who are interested in further exploring this problem in a
real programming language, I found this excellent little collection of

This comment should give you a good idea of how you can build your
algorithm recursively:

    ;; otherwise take an element, e, out of the bag.
    ;; generate all permutations of the remaining elements.
    ;; and add e to the front of each of these.
    ;; do this for all possible e to generate all permutations.

Mmmmmm.... Lisp..... almost as scrumptious as Objective Caml...

                         Michael A. Halcrow                          
       Security Software Engineer, IBM Linux Technology Center       
GnuPG Fingerprint: 419C 5B1E 948A FA73 A54C  20F5 DB40 8531 6DCA 8769

I stole this Sig. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : 

More information about the PLUG mailing list