File: chap2.txt

package info (click to toggle)
gap-utils 0.93-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,504 kB
  • sloc: xml: 2,167; javascript: 155; makefile: 105
file content (61 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  
  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:
  
      by giving a list of positions of items to be printed, or
  
      by specifying a first item and then a regular step.
  
  2.1-1 PrintSelection
  
  PrintSelection( obj, list )  function
  PrintSelection( obj, first, step[, last] )  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.
  
    Example  
    
    gap> L := List( [1..20], n -> n^5 );;
    gap> PrintSelection( L, [18..20] );
    18 : 1889568
    19 : 2476099
    20 : 3200000
    gap> PrintSelection( L, 2, 9 );       
    2 : 32
    11 : 161051
    20 : 3200000
    gap> PrintSelection( L, 2, 3, 11 );
    2 : 32
    5 : 3125
    8 : 32768
    11 : 161051
    gap> s5 := SymmetricGroup( 5 );;
    gap> PrintSelection( s5, [30,31,100,101] );
    30 : (1,5)(3,4)
    31 : (1,5,2)
    100 : (1,4,3)
    101 : (1,4)(3,5)
    gap> PrintSelection( s5, 1, 30 );
    1 : ()
    31 : (1,5,2)
    61 : (1,2,3)
    91 : (1,3,5,2,4)
    gap> PrintSelection( s5, 9, 11, 43 );
    9 : (2,5,3)
    20 : (2,4)
    31 : (1,5,2)
    42 : (1,5,2,3,4)