Skip to content

Commit

Permalink
fixed an error in the default method for PositionNot
Browse files Browse the repository at this point in the history
(and PositionNonZero), in the case that the given 'from' value
is larger than the length of the list
  • Loading branch information
ThomasBreuer committed Sep 7, 2017
1 parent fdaba7a commit adeb73c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/kernel.g
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ POSITION_NOT := function( arg )
return i;
fi;
od;
return LENGTH(arg[1]) + 1;

if LENGTH( arg[1] ) <= arg[3] then
return arg[3] + 1;
else
return LENGTH(arg[1]) + 1;
fi;
else
Error( "usage: PositionNot( <list>, <val>[, <from>] )" );
fi;
Expand Down
16 changes: 16 additions & 0 deletions tst/testinstall/listgen.tst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ gap> PositionBound( [ ,,,, 1 ] );
5
gap> PositionBound( [] );
fail
gap> PositionNot( [ 2, 1 ], 1 );
1
gap> PositionNot( [ 1, 2 ], 1 );
2
gap> PositionNot( [ 1, 1 ], 1 );
3
gap> PositionNot( [ 1, 1 ], 1, 3 );
4
gap> PositionNonZero( [ 1, 1 ] );
1
gap> PositionNonZero( [ 0, 1 ] );
2
gap> PositionNonZero( [ 0, 0 ] );
3
gap> PositionNonZero( [ 0, 0 ], 3 );
4
gap> l:= [ 1 .. 10 ];;
gap> SortParallel( [ 2, 3, 4, 1, 5, 10, 9, 7, 8, 6 ], l );
gap> l;
Expand Down

0 comments on commit adeb73c

Please sign in to comment.