[ccan] [PATCH] permutation: Generate permutations of arrays
David Gibson
david at gibson.dropbear.id.au
Tue Sep 29 01:01:14 AEST 2015
On Sun, Sep 27, 2015 at 04:31:25PM +0930, Paul 'Rusty' Russell wrote:
> David Gibson <david at gibson.dropbear.id.au> writes:
> > + * Example:
> > + * #include <stdio.h>
> > + * #include <ccan/permutation/permutation.h>
> > + *
> > + * int main(int argc, char *argv[])
> > + * {
> > + * int i;
> > + * struct permutation *pi = permutation_new(argc - 1);
> > + *
> > + * do {
> > + * for (i = 1; i <= argc; i++)
> > + * printf("%s ", argv[i]);
> > + * printf("\n");
> > + * } while (permutation_change_array(pi,
> > + * &argv[1], sizeof(argv[1])));
> > + * exit(0);
> > + * }
>
> That is a masterful example. It's not quite right though: (i < argc,
> not i <= argc).
>
> I tried adding:
>
> * // Given 1 2 3 outputs 1 2 3 1 3 2 3 1 2 3 2 1 2 3 1 2 1 3
>
> But ccanlint isn't clever enough to ignore the \n.
>
> Let me fix that now...
Fixed those nits and a couple of others, and committed.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20150929/1a291049/attachment-0001.sig>
More information about the ccan
mailing list