Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Concatenation to reject Concatenation( [ 1 ] ) instead of returning 1, and in general do a better job at validating its inputs #5427

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/coll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2979,14 +2979,14 @@ DeclareOperation( "IsSubset", [ IsListOrCollection, IsListOrCollection ] );

#############################################################################
##
#F Intersection( <C1>, <C2> ... ) . . . . . . . intersection of collections
#F Intersection( <C1>, <C2>, ... ) . . . . . . . intersection of collections
#F Intersection( <list> ) . . . . . . . . . . . intersection of collections
#O Intersection2( <C1>, <C2> ) . . . . . . . . . intersection of collections
##
## <#GAPDoc Label="Intersection">
## <ManSection>
## <Heading>Intersection</Heading>
## <Func Name="Intersection" Arg='C1, C2 ...'
## <Func Name="Intersection" Arg='C1, C2, ...'
## Label="for various collections"/>
## <Func Name="Intersection" Arg='list' Label="for a list"/>
## <Oper Name="Intersection2" Arg='C1, C2'/>
Expand Down Expand Up @@ -3055,14 +3055,14 @@ DeclareOperation( "Intersection2",

#############################################################################
##
#F Union( <C1>, <C2> ... ) . . . . . . . . . . . . . . union of collections
#F Union( <C1>, <C2>, ... ) . . . . . . . . . . . . . union of collections
#F Union( <list> ) . . . . . . . . . . . . . . . . . . union of collections
#O Union2( <C1>, <C2> ) . . . . . . . . . . . . . . . union of collections
##
## <#GAPDoc Label="Union">
## <ManSection>
## <Heading>Union</Heading>
## <Func Name="Union" Arg='C1, C2 ...' Label="for various collections"/>
## <Func Name="Union" Arg='C1, C2, ...' Label="for various collections"/>
## <Func Name="Union" Arg='list' Label="for a list"/>
## <Oper Name="Union2" Arg='C1, C2'/>
##
Expand Down
2 changes: 1 addition & 1 deletion lib/combinat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ DeclareGlobalFunction("NrUnorderedTuples");
## <#GAPDoc Label="IteratorOfCartesianProduct">
## <ManSection>
## <Heading>IteratorOfCartesianProduct</Heading>
## <Func Name="IteratorOfCartesianProduct" Arg='list1, list2 ...'
## <Func Name="IteratorOfCartesianProduct" Arg='list1, list2, ...'
## Label="for several lists"/>
## <Func Name="IteratorOfCartesianProduct" Arg='list'
## Label="for a list of lists"/>
Expand Down
12 changes: 6 additions & 6 deletions lib/list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1824,13 +1824,13 @@ DeclareOperation( "StableSortParallel",

#############################################################################
##
#F Maximum( <obj1>, <obj2> ... ) . . . . . . . . . . . . maximum of objects
#F Maximum( <obj1>, <obj2>, ... ) . . . . . . . . . . . maximum of objects
#F Maximum( <list> )
##
## <#GAPDoc Label="Maximum">
## <ManSection>
## <Heading>Maximum</Heading>
## <Func Name="Maximum" Arg='obj1, obj2 ...' Label="for various objects"/>
## <Func Name="Maximum" Arg='obj1, obj2, ...' Label="for various objects"/>
## <Func Name="Maximum" Arg='list' Label="for a list"/>
##
## <Description>
Expand Down Expand Up @@ -1862,13 +1862,13 @@ DeclareGlobalFunction( "Maximum" );

#############################################################################
##
#F Minimum( <obj1>, <obj2> ... ) . . . . . . . . . . . . minimum of objects
#F Minimum( <obj1>, <obj2>, ... ) . . . . . . . . . . . minimum of objects
#F Minimum( <list> )
##
## <#GAPDoc Label="Minimum">
## <ManSection>
## <Heading>Minimum</Heading>
## <Func Name="Minimum" Arg='obj1, obj2 ...' Label="for various objects"/>
## <Func Name="Minimum" Arg='obj1, obj2, ...' Label="for various objects"/>
## <Func Name="Minimum" Arg='list' Label="for a list"/>
##
## <Description>
Expand Down Expand Up @@ -1940,13 +1940,13 @@ DeclareOperation( "MinimumList", [ IsList, IsObject ] );

#############################################################################
##
#F Cartesian( <list1>, <list2> ... ) . . . . . . cartesian product of lists
#F Cartesian( <list1>, <list2>, ... ) . . . . . cartesian product of lists
#F Cartesian( <list> )
##
## <#GAPDoc Label="Cartesian">
## <ManSection>
## <Heading>Cartesian</Heading>
## <Func Name="Cartesian" Arg='list1, list2 ...'
## <Func Name="Cartesian" Arg='list1, list2, ...'
## Label="for various objects"/>
## <Func Name="Cartesian" Arg='list' Label="for a list"/>
##
Expand Down
8 changes: 7 additions & 1 deletion lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2084,8 +2084,14 @@ InstallGlobalFunction( Concatenation, function ( arg )
if Length( arg ) = 0 then
return [ ];
fi;
if not IsList( arg[1] ) then
Error( "Concatenation: arguments must be lists" );
fi;
res := ShallowCopy( arg[1] );
for i in [ 2 .. Length( arg ) ] do
if not IsList( arg[i] ) then
Error( "Concatenation: arguments must be lists" );
fi;
Append( res, arg[i] );
od;
return res;
Expand Down Expand Up @@ -2797,7 +2803,7 @@ InstallMethod( MinimumList,

#############################################################################
##
#F Cartesian( <list1>, <list2> ... )
#F Cartesian( <list1>, <list2>, ... )
#F Cartesian( <list> )
##
DeclareGlobalName( "Cartesian2" );
Expand Down
18 changes: 18 additions & 0 deletions tst/testinstall/opers/Concatenation.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
gap> START_TEST("Concatenation.tst");

#
gap> Concatenation( );
[ ]
gap> Concatenation( [ ] );
[ ]
gap> Concatenation( [ 1 ] );
Error, Concatenation: arguments must be lists
gap> Concatenation( [ [ 1, 2 ] ] );
[ 1, 2 ]
gap> Concatenation( [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] );
[ 1, 2, 3, 4, 5, 6 ]
gap> Concatenation( [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] );
[ 1, 2, 3, 4, 5, 6 ]

#
gap> STOP_TEST("Concatenation.tst", 1);