All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: ccan@lists.ozlabs.org
Subject: Re: [PATCH] permutation: Generate permutations of arrays
Date: Tue, 29 Sep 2015 01:01:14 +1000	[thread overview]
Message-ID: <20150928150114.GP11620@voom.redhat.com> (raw)
In-Reply-To: <87lhbspcqi.fsf@rustcorp.com.au>


[-- Attachment #1.1: Type: text/plain, Size: 1148 bytes --]

On Sun, Sep 27, 2015 at 04:31:25PM +0930, Paul 'Rusty' Russell wrote:
> 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...

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

  reply	other threads:[~2015-09-28 15:57 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
2015-09-28 15:01   ` David Gibson [this message]
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=20150928150114.GP11620@voom.redhat.com \
    --to=david@gibson.dropbear.id.au \
    --cc=ccan@lists.ozlabs.org \
    --cc=rusty@rustcorp.com.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.