RobinHankin / partitions

R package for integer partitions
9 stars 5 forks source link

repeated code #3

Closed RobinHankin closed 5 years ago

RobinHankin commented 5 years ago

C functions nextperm() and nextmultiset() in files permutations.c and multiset.c are [almost] identical. I had not realised until just now that nextperm() would work with multisets, provided the line

for(j=n-2 ; a[j]>a[j+1] ; j--){ } /* L2 */

is replaced by what it should read which is

for(j=n-2 ; a[j]>=a[j+1] ; j--){ } /* L2 */