Re: [PATCH] permutation: Generate permutations of arrays
Rusty Russell <[email protected]> Sun, 27 Sep 2015 16:31:25 +0930
| Newsgroups | org.ozlabs.lists.ccan |
|---|---|
| Message-ID | <[email protected]> |
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... Cheers, Rusty. _______________________________________________ ccan mailing list [email protected] https://lists.ozlabs.org/listinfo/ccan