Goto Chapter: Top 1 2 3 4 5 6 7 8 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 Printing Lists and Iterators
 2.1 Printing selected items

2 Printing Lists and Iterators

2.1 Printing selected items

The functions described here print lists or objects with an iterator with one item per line, either the whole list/iterator or certain subsets:

2.1-1 PrintOneItemPerLine
‣ PrintOneItemPerLine( obj )( function )

This function calls operations PrintListOneItemPerLine (which has been transferred from package XMod) or PrintIteratorOneItemPerLine.

Printing lists vertically, rather than horizontally, may be useful when the entries are lengthy. This function does this for lists, iterators, and objects which have an iterator.


gap> s3 := SymmetricGroup( 3 );; 
gap> L := KnownPropertiesOfObject( GeneratorsOfGroup( s3 ) );;
gap> PrintOneItemPerLine( L );
[ IsFinite,
  IsSmallList,
  IsGeneratorsOfMagmaWithInverses,
  IsGeneratorsOfSemigroup,
  IsSubsetLocallyFiniteGroup
  ]
gap> PrintOneItemPerLine( s3 ); 
()
(2,3)
(1,3)
(1,3,2)
(1,2,3)
(1,2)

2.1-2 PrintSelection
‣ PrintSelection( obj, first, step[, last] )( function )
‣ PrintSelection( obj, list )( function )

This function, given three (or four) parameters, calls operations PrintSelectionFromList or PrintSelectionFromIterator which prints the first item specified, and then the item at every step. The fourth parameter is essential when the object being printed is infinite.

Alternatively, given two parameters, with the second parameter a list L of positive integers, only the items at positions in L are printed.


gap> L := List( [1..20], n -> n^5 );; 
gap> PrintSelection( L, 1, 8 );
1 : 1
9 : 59049
17 : 1419857
gap> PrintSelection( L, [9..11] );
9 : 59049
10 : 100000
11 : 161051
gap> s5 := SymmetricGroup( 5 );; 
gap> PrintSelection( s5, 12, 30 );
12 : (2,5)(3,4)
42 : (1,5,2,3,4)
72 : (1,2,4,3)
102 : (1,4,3,5)
gap> PrintSelection( s5, [118..122] );
118 : (1,4,3,2,5)
119 : (1,4,2,5,3)
120 : (1,4,3)(2,5)
gap> f2 := FreeGroup( 2 );; 
gap> PrintSelection( f2, 20, 20, 100 ); 
20 : f2*f1^2
40 : f2*f1*f2
60 : f1*f2*f1^2
80 : (f2*f1)^2
100 : f1*f2^2*f1^-1
gap> PrintSelection( f2, [11..15] );
11 : f2^-1*f1^-1
12 : f1*f2
13 : f1^-1*f2
14 : f1*f2^-1
15 : f1^-1*f2^-1

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 Bib Ind

generated by GAPDoc2HTML