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

line breaking hints in the ViewString method for lists #3440

Merged
merged 1 commit into from
May 8, 2019
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
21 changes: 16 additions & 5 deletions lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,21 @@ local str,ls, i;
fi;
od;

str := "[ ";
# The line break hints are consistent with those
# that appear in the kernel function 'PrintListDefault'
# and in the 'ViewObj' method for finite lists.
str:= "\>\>[ \>\>";
for i in [ 1 .. Length( list ) ] do
Append(str,ls[i]);
if i<>Length(list) then
Append(str,",\<\> ");
if ls[i] <> "" then
if 1 < i then
Append( str, "\<,\< \>\>" );
fi;
Append( str, ls[i] );
elif 1 < i then
Append( str, "\<,\<\>\>" );
fi;
od;
Append( str, " ]" );
Append( str, " \<\<\<\<]" );
ConvertToStringRep( str );
return str;
end );
Expand Down Expand Up @@ -3788,6 +3795,10 @@ LIST_WITH_IDENTICAL_ENTRIES );
## method is needed eventually looking out for long list or homogeneous list
## or dense list, etc.
##
## The line break hints are consistent with those
## that appear in the kernel function 'PrintListDefault'
## and in the 'ViewString' method for finite lists.
##
InstallMethod( ViewObj,
"for finite lists",
[ IsList and IsFinite ],
Expand Down
4 changes: 3 additions & 1 deletion src/lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,9 @@ Obj TYPES_LIST_FAM (
*F PrintListDefault(<list>) . . . . . . . . . . . . . . . . . print a list
*F PrintPathList(<list>,<indx>) . . . . . . . . . . . . . print a list path
**
** 'PrintList' simply prints the list.
** 'PrintListDefault' simply prints the elements in the given list.
** The line break hints are consistent with those
** that appear in the 'ViewObj' and 'ViewString' methods for finite lists.
*/
static void PrintListDefault(Obj list)
{
Expand Down
6 changes: 3 additions & 3 deletions tst/testinstall/ctblfuns.tst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ gap> V4:= Group( (1,2)(3,4), (1,3)(2,4) );
Group([ (1,2)(3,4), (1,3)(2,4) ])
gap> irr:= Irr( V4 );
[ Character( CharacterTable( Group([ (1,2)(3,4), (1,3)(2,4) ]) ),
[ 1, 1, 1, 1 ] ), Character( CharacterTable( Group([ (1,2)(3,4), (1,3)
(2,4) ]) ), [ 1, -1, -1, 1 ] ), Character( CharacterTable( Group([ (1,2)
(3,4), (1,3)(2,4) ]) ), [ 1, -1, 1, -1 ] ),
[ 1, 1, 1, 1 ] ), Character( CharacterTable( Group([ (1,2)(3,4), (1,3)(2,4)
]) ), [ 1, -1, -1, 1 ] ), Character( CharacterTable( Group(
[ (1,2)(3,4), (1,3)(2,4) ]) ), [ 1, -1, 1, -1 ] ),
Character( CharacterTable( Group([ (1,2)(3,4), (1,3)(2,4) ]) ),
[ 1, 1, -1, -1 ] ) ]
gap> List( irr, x -> InertiaSubgroup( S4, x ) );
Expand Down
4 changes: 2 additions & 2 deletions tst/testinstall/mapping.tst
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ false
gap> inv:= InverseGeneralMapping( map );
InverseGeneralMapping( <general mapping: GF(3) -> GF(3) > )
gap> AsList( UnderlyingRelation( inv ) );
[ DirectProductElement( [ 0*Z(3), 0*Z(3) ] ), DirectProductElement( [ 0*Z(3),
Z(3)^0 ] ) ]
[ DirectProductElement( [ 0*Z(3), 0*Z(3) ] ),
DirectProductElement( [ 0*Z(3), Z(3)^0 ] ) ]
gap> IsInjective( inv );
true
gap> IsSingleValued( inv );
Expand Down
22 changes: 20 additions & 2 deletions tst/testinstall/strings.tst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ gap> PrintString(x);
gap> String(x);
"[ ]"

# List
# Dense list
gap> x:=[1,2,3];
[ 1, 2, 3 ]
gap> Display(x);
Expand All @@ -126,12 +126,30 @@ gap> PrintObj(x);Print("\n");
gap> DisplayString(x);
"<object>\n"
gap> ViewString(x);
"[ 1,\<\> 2,\<\> 3 ]"
"\>\>[ \>\>1\<,\< \>\>2\<,\< \>\>3 \<\<\<\<]"
gap> PrintString(x);
"[ 1, 2, 3 ]"
gap> String(x);
"[ 1, 2, 3 ]"

# Non-dense list
gap> x:= [ 1,, 3 ];
[ 1,, 3 ]
gap> Display( x );
[ 1,, 3 ]
gap> ViewObj( x ); Print( "\n" );
[ 1,, 3 ]
gap> PrintObj( x ); Print( "\n" );
[ 1,, 3 ]
gap> DisplayString( x );
"<object>\n"
gap> ViewString( x );
"\>\>[ \>\>1\<,\<\>\>\<,\< \>\>3 \<\<\<\<]"
gap> PrintString( x );
"[ 1, , 3 ]"
gap> String( x );
"[ 1, , 3 ]"

# Character
gap> x:='a';
'a'
Expand Down
12 changes: 6 additions & 6 deletions tst/teststandard/reesmat.tst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ gap> mat:=
> (1,6)(2,5)(3,4), 0, 0, 0, 0, 0 ] ];;
gap> R:=ReesZeroMatrixSemigroup(Group([ (1,2)(3,5)(4,6), (1,3)(2,4)(5,6) ]),
> mat);
<Rees 0-matrix semigroup 25x10 over Group([ (1,2)(3,5)(4,6), (1,3)(2,4)
(5,6) ])>
<Rees 0-matrix semigroup 25x10 over Group([ (1,2)(3,5)(4,6), (1,3)(2,4)(5,6)
])>
gap> Size(R);
1501
gap> ForAll(R, x-> x in R);
Expand Down Expand Up @@ -294,8 +294,8 @@ Group([ (1,2,3) ])
gap> HasIsSimpleSemigroup(g);
true
gap> R;
<Rees 0-matrix semigroup 25x10 over Group([ (1,2)(3,5)(4,6), (1,3)(2,4)
(5,6) ])>
<Rees 0-matrix semigroup 25x10 over Group([ (1,2)(3,5)(4,6), (1,3)(2,4)(5,6)
])>
gap> mat:=[[0,0,0], [(1,2), 0, (3,4)]];
[ [ 0, 0, 0 ], [ (1,2), 0, (3,4) ] ]
gap> R:=ReesZeroMatrixSemigroup(SymmetricGroup(4), mat);
Expand Down Expand Up @@ -383,8 +383,8 @@ gap> mat:=
> (1,3,5,7)(2,4,6,8), (1,4,7,2,5,8,3,6), (1,3,5,7)(2,4,6,8),
> (1,8,7,6,5,4,3,2), (1,4,7,2,5,8,3,6), (1,2,3,4,5,6,7,8) ] ];;
gap> R:=ReesMatrixSemigroup(DihedralGroup(IsPermGroup, 16), mat);
<Rees matrix semigroup 9x11 over Group([ (1,2,3,4,5,6,7,8), (2,8)(3,7)
(4,6) ])>
<Rees matrix semigroup 9x11 over Group([ (1,2,3,4,5,6,7,8), (2,8)(3,7)(4,6)
])>
gap> Size(R);
1584
gap> Representative(R);
Expand Down