Skip to content

Commit

Permalink
Fix ShallowCopy for IteratorOfPartitionsSet
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed May 20, 2021
1 parent ea40424 commit ca768cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/combinat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ InstallGlobalFunction( IteratorOfPartitionsSet, function( s )
return out;
end;

shallowCopy := iter -> rec( next := ShallowCopy( iter!.next ) );
shallowCopy := iter -> rec( next := ShallowCopy( iter!.next ), s := iter!.s );

isDone := iter -> iter!.next = false;

Expand Down
24 changes: 8 additions & 16 deletions tst/testinstall/combinat.tst
Original file line number Diff line number Diff line change
Expand Up @@ -461,30 +461,22 @@ gap> NrRestrictedPartitions( 100, [2,3,5,7,11,13,17], 10 );

#F IteratorOfPartitions( <n> )
gap> for n in [ 1 .. 15 ] do
> pn:= Partitions( n );
> iter:= IteratorOfPartitions( n );
> list:= [];
> for i in [ 1 .. Length( pn ) ] do
> Add( list, NextIterator( iter ) );
> od;
> if not IsDoneIterator( iter ) then
> pn1:= Partitions( n );
> pn2:= List( IteratorOfPartitions( n ) );
> if Length(pn1) <> Length(pn2) then
> Error( "wrong number of elements" );
> elif pn <> list then
> elif pn1 <> pn2 then
> Error( "different elements" );
> fi;
> od;

#F IteratorOfPartitionsSet( <set> )
gap> for s in [[], [5], [1,2,3,4], [2,5,7], ["a","b","c","d","e"], [3..13]] do
> pn:= PartitionsSet( s );
> iter:= IteratorOfPartitionsSet( s );
> list:= [];
> for i in [ 1 .. Length( pn ) ] do
> Add( list, NextIterator( iter ) );
> od;
> if not IsDoneIterator( iter ) then
> pn1:= PartitionsSet( s );
> pn2:= List( IteratorOfPartitionsSet( s ) );
> if Length(pn1) <> Length(pn2) then
> Error( "wrong number of elements" );
> elif Set(pn) <> Set(list) then
> elif Set(pn1) <> Set(pn2) then
> Error( "different elements" );
> fi;
> od;
Expand Down

0 comments on commit ca768cc

Please sign in to comment.