public inbox for ccan@ozlabs.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: David Gibson <david@gibson.dropbear.id.au>, ccan@lists.ozlabs.org
Subject: Re: [PATCH] permutation: Generate permutations of arrays
Date: Sun, 27 Sep 2015 16:31:25 +0930	[thread overview]
Message-ID: <87lhbspcqi.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1443269503-21685-1-git-send-email-david@gibson.dropbear.id.au>

David Gibson <david@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...

Cheers,
Rusty.
_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

  reply	other threads:[~2015-09-28  0:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-26 12:11 [PATCH] permutation: Generate permutations of arrays David Gibson
2015-09-27  7:01 ` Rusty Russell [this message]
2015-09-28 15:01   ` David Gibson
2015-09-27  7:04 ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhbspcqi.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=ccan@lists.ozlabs.org \
    --cc=david@gibson.dropbear.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox