help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] combination/demo.c


From: Rhys Ulerich
Subject: Re: [Help-gsl] combination/demo.c
Date: Sun, 16 Dec 2012 14:44:09 -0600

Hi Jorge,

> In demo.c there is two equal lines together:
>
>   while (gsl_combination_next(c) == GSL_SUCCESS);
>   while (gsl_combination_next(c) == GSL_SUCCESS);
>
> Is it OK???

I'm guessing you mean combination/demo.c?  The full context is...

  printf("combinations %u choose %u\n", n, k);
  do
    {
      gsl_combination_fprintf (stdout, c, " %u");
      printf("\n");
    }
  while (gsl_combination_next(c) == GSL_SUCCESS);
  while (gsl_combination_next(c) == GSL_SUCCESS);
  do
    {
      gsl_combination_fprintf (stdout, c, " %u");
      printf("\n");
    }
  while (gsl_combination_prev(c) == GSL_SUCCESS);

That's a do-while loop, a while loop with no body, and another
do-while loop.  I suspect the second while statement you identified
(the while loop with no body) has no useful effect.   I say that
because the first do-while loop terminates when gsl_combination_next
returns something other than GSL_SUCCESS and the test in the second
while statement should receive the same result.  Control would
immediately proceed to the final do-while loop.

So... OK?  Probably as it should be harmless.  Ideal, no.

Removed it in http://bzr.savannah.gnu.org/lh/gsl/trunk/revision/4787

- Rhys



reply via email to

[Prev in Thread] Current Thread [Next in Thread]