Re: [PATCH] permutation: Generate permutations of arrays
David Gibson <[email protected]> Tue, 29 Sep 2015 01:01:14 +1000
| Newsgroups | org.ozlabs.lists.ccan |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Sep 27, 2015 at 04:31:25PM +0930, Paul 'Rusty' Russell wrote: > David Gibson <[email protected]> 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 _______________________________________________ ccan mailing list [email protected] https://lists.ozlabs.org/listinfo/ccan
signature.asc
(application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWCVY6AAoJEGw4ysog2bOSuGcP/33RsXZp0730dFqxrA/6iVFS 1akQkzaQd59eutgls+jPCa8EG+1revsiXpxja5DOYrxoL500MsuhajjdW4SK/GT0 ocKnK4yGyVYlzB550NRO4miiRIDkP9WTPsDP7YlMUvmvA0vRn1XS/KTGXae3JLR8 Xd398yIAN7IZ7dg4CMDLqENDLFtGcbNB78PDVobDgarUbXXSmvjc3y0pYJCJ2VlI Bbp+KMu9AkVHIrO6fR9e5XsO/zkp3E3Wbz7GGzg26wZNF4jabUr8RcpnroK3PKVU kjXQ+UtbwkO3xzj/ej6UR8e3AyClh9JyOQsxz2FtVHkdpObQ2XcyZiXOr0KwsZYr 20oFqiKCi/TCtM0Qw0dCqiogHWkLP+7WDfXnppT7uJ1zxu9aj6WyeSJIePxB+TB7 JohZD5v6F0+sMprv/vCBjEEf4u/GYGAHD/0rgOM1Bc/07j2upARWKLvDZ1lgW0nx bZI7MszdpLsgJxG7Q6eE5tgUcD2SEyo3KKldNSomcZCZjCfQf17vYbG2o9aUXdhP wG2SKNBL9k6tJQZbHJnzo9mvvEkTMofoKOa1bUZeh20GN8I1tj22VxE25DR9rglM yZoHh7eOHS7q37UZiLwD0k7sQaqVuR/eo9wdfTFO64kvXDjPMh0VUgoWDWhsBeLS psCM+lfP/QWA5lHgV7rB =04FB -----END PGP SIGNATURE-----