This file is indexed.

/usr/share/gap/doc/ref/chap30.html is in gap-doc 4r8p6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 30: Collections</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap30"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap29.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap31.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap30_mj.html">[MathJax on]</a></p>
<p><a id="X8050A8037984E5B6" name="X8050A8037984E5B6"></a></p>
<div class="ChapSects"><a href="chap30.html#X8050A8037984E5B6">30 <span class="Heading">Collections</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X8084F03A78ABD4F8">30.1 <span class="Heading">IsCollection (Filter)</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X79C9FC7F86E2738C">30.1-1 IsCollection</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X85D8D8F684B02DDF">30.2 <span class="Heading">Collection Families</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X84E5A67E87D8DD66">30.2-1 CollectionsFamily</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X856AC2DF7F7CBAAF">30.2-2 IsCollectionFamily</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X864BB3748546F63F">30.2-3 ElementsFamily</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X78C38017804B2EA7">30.2-4 CategoryCollections</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X7C3722DF8736FFDB">30.3 <span class="Heading">Lists and Collections</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X877128A77826DD69">30.3-1 IsListOrCollection</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7EF8910F82B45EC7">30.3-2 Enumerator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X80CD7DDC7D0C60D5">30.3-3 EnumeratorSorted</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X85E149177AC547C3">30.3-4 EnumeratorByFunctions</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7F12F40E87F3C3A7">30.3-5 List</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X82CE157A7FAD8036">30.3-6 SortedList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7E399AC97FD98217">30.3-7 SSortedList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X8289FCCC8274C89D">30.3-8 AsList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7BCA5C6181391007">30.3-9 AsSortedList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X856D927378C33548">30.3-10 AsSSortedList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X79B130FC7906FB4C">30.3-11 Elements</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X79AD18737E70B414">30.4 <span class="Heading">Attributes and Properties for Collections</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7969C48780C5C1BC">30.4-1 IsEmpty</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X808A4061809A6E67">30.4-2 IsFinite</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7E3402D6799D3C24">30.4-3 IsTrivial</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7F192373850B85B9">30.4-4 IsNonTrivial</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X78EF6A137E8F66B0">30.4-5 IsWholeFamily</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X858ADA3B7A684421">30.4-6 Size</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X865507568182424E">30.4-7 Representative</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X8026085680270D37">30.4-8 RepresentativeSmallest</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X7F8FEA3278239ADE">30.5 <span class="Heading">Operations for Collections</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X79CA175481F8105F">30.5-1 IsSubset</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X851069107CACF98E">30.5-2 <span class="Heading">Intersection</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X799F0E2F7A502DBA">30.5-3 <span class="Heading">Union</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X825AC0F07E010B07">30.5-4 Difference</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X82D39CF980FDBFFA">30.6 <span class="Heading">Membership Test for Collections</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X84B7FA8C7C94400F">30.6-1 \in</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X8151A51884B7EE2C">30.7 <span class="Heading">Random Elements</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7FF906E57D6936F8">30.7-1 Random</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X811B5BD47DC5356B">30.7-2 PseudoRandom</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7EBA01EB83BC65A9">30.7-3 RandomList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap30.html#X85A3F00985453F95">30.8 <span class="Heading">Iterators</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X83ADF8287ED0668E">30.8-1 Iterator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X8688C20B828FC129">30.8-2 IteratorSorted</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X87168A827E5B28E4">30.8-3 IsIterator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X8055FC557B5D899E">30.8-4 IsDoneIterator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X879F62F77D1D1179">30.8-5 NextIterator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X858A28667D137C4B">30.8-6 IteratorList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X7DB80BE68271247E">30.8-7 TrivialIterator</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap30.html#X82677D8F817D6701">30.8-8 IteratorByFunctions</a></span>
</div></div>
</div>

<h3>30 <span class="Heading">Collections</span></h3>

<p>A <em>collection</em> in <strong class="pkg">GAP</strong> consists of elements in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). The most important kinds of collections are <em>homogeneous lists</em> (see <a href="chap21.html#X7B256AE5780F140A"><span class="RefLink">21</span></a>) and <em>domains</em> (see <a href="chap12.html#X7BAF69417BB925F6"><span class="RefLink">12.4</span></a>). Note that a list is never a domain, and a domain is never a list. A list is a collection if and only if it is nonempty and homogeneous.</p>

<p>Basic operations for collections are <code class="func">Size</code> (<a href="chap30.html#X858ADA3B7A684421"><span class="RefLink">30.4-6</span></a>) and <code class="func">Enumerator</code> (<a href="chap30.html#X7EF8910F82B45EC7"><span class="RefLink">30.3-2</span></a>); for <em>finite</em> collections, <code class="func">Enumerator</code> (<a href="chap30.html#X7EF8910F82B45EC7"><span class="RefLink">30.3-2</span></a>) admits to delegate the other operations for collections (see <a href="chap30.html#X79AD18737E70B414"><span class="RefLink">30.4</span></a> and <a href="chap30.html#X7F8FEA3278239ADE"><span class="RefLink">30.5</span></a>) to functions for lists (see <a href="chap21.html#X7B256AE5780F140A"><span class="RefLink">21</span></a>). Obviously, special methods depending on the arguments are needed for the computation of e.g. the intersection of two <em>infinite</em> domains.</p>

<p><a id="X8084F03A78ABD4F8" name="X8084F03A78ABD4F8"></a></p>

<h4>30.1 <span class="Heading">IsCollection (Filter)</span></h4>

<p><a id="X79C9FC7F86E2738C" name="X79C9FC7F86E2738C"></a></p>

<h5>30.1-1 IsCollection</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsCollection</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>tests whether an object is a collection.</p>

<p>Some of the functions for lists and collections are described in the chapter about lists, mainly in Section <a href="chap21.html#X7DF510F7848CBBFD"><span class="RefLink">21.20</span></a>. In the current chapter, we describe those functions for which the "collection aspect" seems to be more important than the "list aspect".</p>

<p><a id="X85D8D8F684B02DDF" name="X85D8D8F684B02DDF"></a></p>

<h4>30.2 <span class="Heading">Collection Families</span></h4>

<p><a id="X84E5A67E87D8DD66" name="X84E5A67E87D8DD66"></a></p>

<h5>30.2-1 CollectionsFamily</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CollectionsFamily</code>( <var class="Arg">Fam</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>For a family <var class="Arg">Fam</var>, <code class="func">CollectionsFamily</code> returns the family of all collections over <var class="Arg">Fam</var>, that is, of all dense lists and domains that consist of objects in <var class="Arg">Fam</var>.</p>

<p>The <code class="func">NewFamily</code> (<a href="chap79.html#X7FB4123E7E22137D"><span class="RefLink">79.7-1</span></a>) call in the standard method of <code class="func">CollectionsFamily</code> is executed with second argument <code class="func">IsCollection</code> (<a href="chap30.html#X79C9FC7F86E2738C"><span class="RefLink">30.1-1</span></a>), since every object in the collections family must be a collection, and with third argument the collections categories of the involved categories in the implied filter of <var class="Arg">Fam</var>.</p>

<p>Note that families (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>) are used to describe relations between objects. Important such relations are that between an element <span class="SimpleMath">e</span> and each collection of elements that lie in the same family as <span class="SimpleMath">e</span>, and that between two collections whose elements lie in the same family. Therefore, all collections of elements in the family <var class="Arg">Fam</var> form the new family <code class="code">CollectionsFamily( <var class="Arg">Fam</var> )</code>.</p>

<p><a id="X856AC2DF7F7CBAAF" name="X856AC2DF7F7CBAAF"></a></p>

<h5>30.2-2 IsCollectionFamily</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsCollectionFamily</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>is <code class="keyw">true</code> if <var class="Arg">Fam</var> is a family of collections, and <code class="keyw">false</code> otherwise.</p>

<p><a id="X864BB3748546F63F" name="X864BB3748546F63F"></a></p>

<h5>30.2-3 ElementsFamily</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ElementsFamily</code>( <var class="Arg">Fam</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>If <var class="Arg">Fam</var> is a collections family (see <code class="func">IsCollectionFamily</code> (<a href="chap30.html#X856AC2DF7F7CBAAF"><span class="RefLink">30.2-2</span></a>)) then <code class="func">ElementsFamily</code> returns the family from which <var class="Arg">Fam</var> was created by <code class="func">CollectionsFamily</code> (<a href="chap30.html#X84E5A67E87D8DD66"><span class="RefLink">30.2-1</span></a>). The way a collections family is created, it always has its elements family stored. If <var class="Arg">Fam</var> is not a collections family then an error is signalled.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">fam:= FamilyObj( (1,2) );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">collfam:= CollectionsFamily( fam );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">fam = collfam;  fam = ElementsFamily( collfam );</span>
false
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">collfam = FamilyObj( [ (1,2,3) ] );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">collfam = FamilyObj( Group( () ) );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">collfam = CollectionsFamily( collfam );</span>
false
</pre></div>

<p><a id="X78C38017804B2EA7" name="X78C38017804B2EA7"></a></p>

<h5>30.2-4 CategoryCollections</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CategoryCollections</code>( <var class="Arg">filter</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Let <var class="Arg">filter</var> be a filter that is <code class="keyw">true</code> for all elements of a family <var class="Arg">Fam</var>, by the construction of <var class="Arg">Fam</var>. Then <code class="func">CategoryCollections</code> returns the <em>collections category</em> of <var class="Arg">filter</var>. This is a category that is <code class="keyw">true</code> for all elements in <code class="code">CollectionsFamily( <var class="Arg">Fam</var> )</code>.</p>

<p>For example, the construction of <code class="func">PermutationsFamily</code> (<a href="chap42.html#X819628B083B3939B"><span class="RefLink">42.1-3</span></a>) guarantees that each of its elements lies in the filter <code class="func">IsPerm</code> (<a href="chap42.html#X7AA69C6686FC49EA"><span class="RefLink">42.1-1</span></a>), and each collection of permutations (permutation group or dense list of permutations) lies in the category <code class="code">CategoryCollections( IsPerm )</code>. <code class="code">CategoryCollections( IsPerm )</code>. Note that this works only if the collections category is created <em>before</em> the collections family. So it is necessary to construct interesting collections categories immediately after the underlying category has been created.</p>

<p><a id="X7C3722DF8736FFDB" name="X7C3722DF8736FFDB"></a></p>

<h4>30.3 <span class="Heading">Lists and Collections</span></h4>

<p>The following functions take a <em>list or collection</em> as argument, and return a corresponding <em>list</em>. They differ in whether or not the result is mutable or immutable (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>), guaranteed to be sorted, or guaranteed to admit list access in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)).</p>

<p><a id="X877128A77826DD69" name="X877128A77826DD69"></a></p>

<h5>30.3-1 IsListOrCollection</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsListOrCollection</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>Several functions are defined for both lists and collections, for example <code class="func">Intersection</code> (<a href="chap30.html#X851069107CACF98E"><span class="RefLink">30.5-2</span></a>), <code class="func">Iterator</code> (<a href="chap30.html#X83ADF8287ED0668E"><span class="RefLink">30.8-1</span></a>), and <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>). <code class="func">IsListOrCollection</code> is a supercategory of <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) and <code class="func">IsCollection</code> (<a href="chap30.html#X79C9FC7F86E2738C"><span class="RefLink">30.1-1</span></a>) (that is, all lists and collections lie in this category), which is used to describe the arguments of functions such as the ones listed above.</p>

<p><a id="X7EF8910F82B45EC7" name="X7EF8910F82B45EC7"></a></p>

<h5>30.3-2 Enumerator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Enumerator</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">Enumerator</code> returns an immutable list <span class="SimpleMath">enum</span>. If the argument is a list (which may contain holes), then <code class="code">Length( </code><span class="SimpleMath">enum</span><code class="code"> )</code> is the length of this list, and <span class="SimpleMath">enum</span> contains the elements (and holes) of this list in the same order. If the argument is a collection that is not a list, then <code class="code">Length( </code><span class="SimpleMath">enum</span><code class="code"> )</code> is the number of different elements of <var class="Arg">C</var>, and <span class="SimpleMath">enum</span> contains the different elements of the collection in an unspecified order, which may change for repeated calls of <code class="func">Enumerator</code>. <span class="SimpleMath">enum[pos]</span> may not execute in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <span class="SimpleMath">enum</span> in memory is as small as is feasible.</p>

<p>For lists, the default method is <code class="func">Immutable</code> (<a href="chap12.html#X7F0ABF2C870B0CBB"><span class="RefLink">12.6-3</span></a>). For collections that are not lists, there is no default method.</p>

<p><a id="X80CD7DDC7D0C60D5" name="X80CD7DDC7D0C60D5"></a></p>

<h5>30.3-3 EnumeratorSorted</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; EnumeratorSorted</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">EnumeratorSorted</code> returns an immutable list <span class="SimpleMath">enum</span>. The argument must be a collection or a list <var class="Arg">listorcoll</var> which may contain holes but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). <code class="code">Length( </code><span class="SimpleMath">enum</span><code class="code"> )</code> is the number of different elements of the argument, and <span class="SimpleMath">enum</span> contains the different elements in sorted order, w.r.t. <code class="code">&lt;</code>. <span class="SimpleMath">enum[pos]</span> may not execute in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <span class="SimpleMath">enum</span> in memory is as small as is feasible.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Enumerator( [ 1, 3,, 2 ] );</span>
[ 1, 3,, 2 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">enum:= Enumerator( Rationals );;  elm:= enum[ 10^6 ];</span>
-69/907
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Position( enum, elm );</span>
1000000
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( enum );  IsSortedList( enum );</span>
false
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsConstantTimeAccessList( enum );</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">EnumeratorSorted( [ 1, 3,, 2 ] );</span>
[ 1, 2, 3 ]
</pre></div>

<p><a id="X85E149177AC547C3" name="X85E149177AC547C3"></a></p>

<h5>30.3-4 EnumeratorByFunctions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; EnumeratorByFunctions</code>( <var class="Arg">D</var>, <var class="Arg">record</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; EnumeratorByFunctions</code>( <var class="Arg">Fam</var>, <var class="Arg">record</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">EnumeratorByFunctions</code> returns an immutable, dense, and duplicate-free list <span class="SimpleMath">enum</span> for which <code class="func">IsBound</code> (<a href="chap21.html#X79EC565A7DCEC938"><span class="RefLink">21.5-1</span></a>), element access via <code class="func">\[\]</code> (<a href="chap21.html#X8297BBCD79642BE6"><span class="RefLink">21.2-1</span></a>), <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>), and <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>) are computed via prescribed functions.</p>

<p>Let <var class="Arg">record</var> be a record with at least the following components.</p>


<dl>
<dt><strong class="Mark"><code class="code">ElementNumber</code></strong></dt>
<dd><p>a function taking two arguments <var class="Arg">enum</var> and <var class="Arg">pos</var>, which returns <code class="code"><var class="Arg">enum</var>[ <var class="Arg">pos</var> ]</code> (see <a href="chap21.html#X7B202D147A5C2884"><span class="RefLink">21.2</span></a>); it can be assumed that the argument <var class="Arg">pos</var> is a positive integer, but <var class="Arg">pos</var> may be larger than the length of <var class="Arg">enum</var> (in which case an error must be signalled); note that the result must be immutable since <var class="Arg">enum</var> itself is immutable,</p>

</dd>
<dt><strong class="Mark"><code class="code">NumberElement</code></strong></dt>
<dd><p>a function taking two arguments <var class="Arg">enum</var> and <var class="Arg">elm</var>, which returns <code class="code">Position( <var class="Arg">enum</var>, <var class="Arg">elm</var> )</code> (see <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>)); it cannot be assumed that <var class="Arg">elm</var> is really contained in <var class="Arg">enum</var> (and <code class="keyw">fail</code> must be returned if not); note that for the three argument version of <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>), the method that is available for duplicate-free lists suffices.</p>

</dd>
</dl>
<p>Further (data) components may be contained in <var class="Arg">record</var> which can be used by these function.</p>

<p>If the first argument is a domain <var class="Arg">D</var> then <var class="Arg">enum</var> lists the elements of <var class="Arg">D</var> (in general <var class="Arg">enum</var> is <em>not</em> sorted), and methods for <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>), <code class="func">IsBound</code> (<a href="chap21.html#X79EC565A7DCEC938"><span class="RefLink">21.5-1</span></a>), and <code class="func">PrintObj</code> (<a href="chap6.html#X815BF22186FD43C9"><span class="RefLink">6.3-5</span></a>) may use <var class="Arg">D</var>.</p>

<p>If one wants to describe the result without creating a domain then the elements are given implicitly by the functions in <var class="Arg">record</var>, and the first argument must be a family <var class="Arg">Fam</var> which will become the family of <var class="Arg">enum</var>; if <var class="Arg">enum</var> is not homogeneous then <var class="Arg">Fam</var> must be <code class="code">ListsFamily</code>, otherwise it must be the collections family of any element in <var class="Arg">enum</var>. In this case, additionally the following component in <var class="Arg">record</var> is needed.</p>


<dl>
<dt><strong class="Mark"><code class="code">Length</code></strong></dt>
<dd><p>a function taking the argument <var class="Arg">enum</var>, which returns the length of <var class="Arg">enum</var> (see <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>)).</p>

</dd>
</dl>
<p>The following components are optional; they are used if they are present but default methods are installed for the case that they are missing.</p>


<dl>
<dt><strong class="Mark"><code class="code">IsBound\[\]</code></strong></dt>
<dd><p>a function taking two arguments <var class="Arg">enum</var> and <var class="Arg">k</var>, which returns <code class="code">IsBound( <var class="Arg">enum</var>[ <var class="Arg">k</var> ] )</code> (see <a href="chap21.html#X7B202D147A5C2884"><span class="RefLink">21.2</span></a>); if this component is missing then <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>) is used for computing the result,</p>

</dd>
<dt><strong class="Mark"><code class="code">Membership</code></strong></dt>
<dd><p>a function taking two arguments <var class="Arg">elm</var> and <var class="Arg">enum</var>, which returns <code class="keyw">true</code> is <var class="Arg">elm</var> is an element of <var class="Arg">enum</var>, and <code class="keyw">false</code> otherwise (see <a href="chap21.html#X7B202D147A5C2884"><span class="RefLink">21.2</span></a>); if this component is missing then <code class="code">NumberElement</code> is used for computing the result,</p>

</dd>
<dt><strong class="Mark"><code class="code">AsList</code></strong></dt>
<dd><p>a function taking one argument <var class="Arg">enum</var>, which returns a list with the property that the access to each of its elements will take roughly the same time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)); if this component is missing then <code class="func">ConstantTimeAccessList</code> (<a href="chap21.html#X7B55FB967CDEF468"><span class="RefLink">21.17-6</span></a>) is used for computing the result,</p>

</dd>
<dt><strong class="Mark"><code class="code">ViewObj</code> and <code class="code">PrintObj</code></strong></dt>
<dd><p>two functions that print what one wants to be printed when <code class="code">View( <var class="Arg">enum</var> )</code> or <code class="code">Print( <var class="Arg">enum</var> )</code> is called (see <a href="chap6.html#X8074A8387C9DB9A8"><span class="RefLink">6.3</span></a>), if the <code class="code">ViewObj</code> component is missing then the <code class="code">PrintObj</code> method is used as a default.</p>

</dd>
</dl>
<p>If the result is known to have additional properties such as being strictly sorted (see <code class="func">IsSSortedList</code> (<a href="chap21.html#X80CDAF45782E8DCB"><span class="RefLink">21.17-4</span></a>)) then it can be useful to set these properties after the construction of the enumerator, before it is used for the first time. And in the case that a new sorted enumerator of a domain is implemented via <code class="func">EnumeratorByFunctions</code>, and this construction is installed as a method for the operation <code class="func">Enumerator</code> (<a href="chap30.html#X7EF8910F82B45EC7"><span class="RefLink">30.3-2</span></a>), then it should be installed also as a method for <code class="func">EnumeratorSorted</code> (<a href="chap30.html#X80CD7DDC7D0C60D5"><span class="RefLink">30.3-3</span></a>).</p>

<p>Note that it is <em>not</em> checked that <code class="func">EnumeratorByFunctions</code> really returns a dense and duplicate-free list. <code class="func">EnumeratorByFunctions</code> does <em>not</em> make a shallow copy of <var class="Arg">record</var>, this record is changed in place, see <a href="chap79.html#X82E86CF37B123FD4"><span class="RefLink">79.9</span></a>.</p>

<p>It would be easy to implement a slightly generalized setup for enumerators that need not be duplicate-free (where the three argument version of <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>) is supported), but the resulting overhead for the methods seems not to be justified.</p>

<p><a id="X7F12F40E87F3C3A7" name="X7F12F40E87F3C3A7"></a></p>

<h5>30.3-5 List</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; List</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For a collection <var class="Arg">C</var> (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>) that is not a list, <code class="func">List</code> returns a new mutable list <var class="Arg">new</var> such that <code class="code">Length( <var class="Arg">new</var> )</code> is the number of different elements of <var class="Arg">C</var>, and <var class="Arg">new</var> contains the different elements of <var class="Arg">C</var> in an unspecified order which may change for repeated calls. <code class="code"><var class="Arg">new</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">new</var> is proportional to its length. The generic method for this case is <code class="code">ShallowCopy( Enumerator( <var class="Arg">C</var> ) )</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= List( Group( (1,2,3) ) );</span>
[ (), (1,3,2), (1,2,3) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSortedList( l );  IsConstantTimeAccessList( l );</span>
true
false
true
</pre></div>

<p>(See also <code class="func">List</code> (<a href="chap21.html#X86CB7DCE8510F977"><span class="RefLink">21.20-19</span></a>).)</p>

<p><a id="X82CE157A7FAD8036" name="X82CE157A7FAD8036"></a></p>

<h5>30.3-6 SortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SortedList</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">SortedList</code> returns a new mutable and dense list <var class="Arg">new</var>. The argument must be a collection or list <var class="Arg">listorcoll</var> which may contain holes but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). <code class="code">Length( <var class="Arg">new</var> )</code> is the number of elements of <var class="Arg">listorcoll</var>, and <var class="Arg">new</var> contains the elements in sorted order, w.r.t. <code class="code">&lt;=</code>. <code class="code"><var class="Arg">new</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">new</var> in memory is proportional to its length.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= SortedList( Group( (1,2,3) ) );</span>
[ (), (1,2,3), (1,3,2) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSortedList( l );  IsConstantTimeAccessList( l );</span>
true
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SortedList( [ 1, 2, 1,, 3, 2 ] );</span>
[ 1, 1, 2, 2, 3 ]
</pre></div>

<p><a id="X7E399AC97FD98217" name="X7E399AC97FD98217"></a></p>

<h5>30.3-7 SSortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SSortedList</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Set</code>( <var class="Arg">C</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">SSortedList</code> ("strictly sorted list") returns a new dense, mutable, and duplicate free list <var class="Arg">new</var>. The argument must be a collection or list <var class="Arg">listorcoll</var> which may contain holes but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). <code class="code">Length( <var class="Arg">new</var> )</code> is the number of different elements of <var class="Arg">listorcoll</var>, and <var class="Arg">new</var> contains the different elements in strictly sorted order, w.r.t. <code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>). <code class="code"><var class="Arg">new</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">new</var> in memory is proportional to its length.</p>

<p><code class="func">Set</code> is simply a synonym for <code class="func">SSortedList</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= SSortedList( Group( (1,2,3) ) );</span>
[ (), (1,2,3), (1,3,2) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSSortedList( l );  IsConstantTimeAccessList( l );</span>
true
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SSortedList( [ 1, 2, 1,, 3, 2 ] );</span>
[ 1, 2, 3 ]
</pre></div>

<p><a id="X8289FCCC8274C89D" name="X8289FCCC8274C89D"></a></p>

<h5>30.3-8 AsList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AsList</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">AsList</code> returns a immutable list <var class="Arg">imm</var>. If the argument is a list (which may contain holes), then <code class="code">Length( <var class="Arg">imm</var> )</code> is the <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>) value of this list, and <var class="Arg">imm</var> contains the elements (and holes) of of the list in the same order. If the argument is a collection that is not a list, then <code class="code">Length( <var class="Arg">imm</var> )</code> is the number of different elements of this collection, and <var class="Arg">imm</var> contains the different elements of the collection in an unspecified order, which may change for repeated calls of <code class="func">AsList</code>. <code class="code"><var class="Arg">imm</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">imm</var> in memory is proportional to its length.</p>

<p>If you expect to do many element tests in the resulting list, it might be worth to use a sorted list instead, using <code class="func">AsSSortedList</code> (<a href="chap30.html#X856D927378C33548"><span class="RefLink">30.3-10</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= AsList( [ 1, 3, 3,, 2 ] );</span>
[ 1, 3, 3,, 2 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSortedList( l );  IsConstantTimeAccessList( l );</span>
false
false
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">AsList( Group( (1,2,3), (1,2) ) );</span>
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
</pre></div>

<p><a id="X7BCA5C6181391007" name="X7BCA5C6181391007"></a></p>

<h5>30.3-9 AsSortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AsSortedList</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">AsSortedList</code> returns a dense and immutable list <var class="Arg">imm</var>. The argument must be a collection or list <var class="Arg">listorcoll</var> which may contain holes but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). <code class="code">Length( <var class="Arg">imm</var> )</code> is the number of elements of the argument, and <var class="Arg">imm</var> contains the elements in sorted order, w.r.t. <code class="code">&lt;=</code>. <code class="code"><var class="Arg">new</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">imm</var> in memory is proportional to its length.</p>

<p>The only difference to the operation <code class="func">SortedList</code> (<a href="chap30.html#X82CE157A7FAD8036"><span class="RefLink">30.3-6</span></a>) is that <code class="func">AsSortedList</code> returns an <em>immutable</em> list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= AsSortedList( [ 1, 3, 3,, 2 ] );</span>
[ 1, 2, 3, 3 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSortedList( l );  IsConstantTimeAccessList( l );</span>
false
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSSortedList( l );</span>
false
</pre></div>

<p><a id="X856D927378C33548" name="X856D927378C33548"></a></p>

<h5>30.3-10 AsSSortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AsSSortedList</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AsSet</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">AsSSortedList</code> ("as strictly sorted list") returns a dense, immutable, and duplicate free list <var class="Arg">imm</var>. The argument must be a collection or list <var class="Arg">listorcoll</var> which may contain holes but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). <code class="code">Length( <var class="Arg">imm</var> )</code> is the number of different elements of <var class="Arg">listorcoll</var>, and <var class="Arg">imm</var> contains the different elements in strictly sorted order, w.r.t. <code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>). <code class="code"><var class="Arg">imm</var>[<var class="Arg">pos</var>]</code> executes in constant time (see <code class="func">IsConstantTimeAccessList</code> (<a href="chap21.html#X7C84E16A85C99C8C"><span class="RefLink">21.1-6</span></a>)), and the size of <var class="Arg">imm</var> in memory is proportional to its length.</p>

<p>Because the comparisons required for sorting can be very expensive for some kinds of objects, you should use <code class="func">AsList</code> (<a href="chap30.html#X8289FCCC8274C89D"><span class="RefLink">30.3-8</span></a>) instead if you do not require the result to be sorted.</p>

<p>The only difference to the operation <code class="func">SSortedList</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>) is that <code class="func">AsSSortedList</code> returns an <em>immutable</em> list.</p>

<p><code class="func">AsSet</code> is simply a synonym for <code class="func">AsSSortedList</code>.</p>

<p>In general a function that returns a set of elements is free, in fact encouraged, to return a domain instead of the proper set of its elements. This allows one to keep a given structure, and moreover the representation by a domain object is usually more space efficient. <code class="func">AsSSortedList</code> must of course <em>not</em> do this, its only purpose is to create the proper set of elements.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= AsSSortedList( l );</span>
[ 1, 2, 3 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMutable( l );  IsSSortedList( l );  IsConstantTimeAccessList( l );</span>
false
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">AsSSortedList( Group( (1,2,3), (1,2) ) );</span>
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
</pre></div>

<p><a id="X79B130FC7906FB4C" name="X79B130FC7906FB4C"></a></p>

<h5>30.3-11 Elements</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Elements</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">Elements</code> does the same as <code class="func">AsSSortedList</code> (<a href="chap30.html#X856D927378C33548"><span class="RefLink">30.3-10</span></a>), that is, the return value is a strictly sorted list of the elements in the list or collection <var class="Arg">C</var>.</p>

<p><code class="func">Elements</code> is only supported for backwards compatibility. In many situations, the sortedness of the "element list" for a collection is in fact not needed, and one can save a lot of time by asking for a list that is <em>not</em> necessarily sorted, using <code class="func">AsList</code> (<a href="chap30.html#X8289FCCC8274C89D"><span class="RefLink">30.3-8</span></a>). If one is really interested in the strictly sorted list of elements in <var class="Arg">C</var> then one should use <code class="func">AsSet</code> (<a href="chap30.html#X856D927378C33548"><span class="RefLink">30.3-10</span></a>) or <code class="func">AsSSortedList</code> (<a href="chap30.html#X856D927378C33548"><span class="RefLink">30.3-10</span></a>) instead.</p>

<p><a id="X79AD18737E70B414" name="X79AD18737E70B414"></a></p>

<h4>30.4 <span class="Heading">Attributes and Properties for Collections</span></h4>

<p><a id="X7969C48780C5C1BC" name="X7969C48780C5C1BC"></a></p>

<h5>30.4-1 IsEmpty</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsEmpty</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p><code class="func">IsEmpty</code> returns <code class="keyw">true</code> if the collection or list <var class="Arg">listorcoll</var> is <em>empty</em> (that is it contains no elements), and <code class="keyw">false</code> otherwise.</p>

<p><a id="X808A4061809A6E67" name="X808A4061809A6E67"></a></p>

<h5>30.4-2 IsFinite</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsFinite</code>( <var class="Arg">C</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p><code class="func">IsFinite</code> returns <code class="keyw">true</code> if the collection <var class="Arg">C</var> is finite, and <code class="keyw">false</code> otherwise.</p>

<p>The default method for <code class="func">IsFinite</code> checks the size (see <code class="func">Size</code> (<a href="chap30.html#X858ADA3B7A684421"><span class="RefLink">30.4-6</span></a>)) of <var class="Arg">C</var>.</p>

<p>Methods for <code class="func">IsFinite</code> may call <code class="func">Size</code> (<a href="chap30.html#X858ADA3B7A684421"><span class="RefLink">30.4-6</span></a>), but methods for <code class="func">Size</code> (<a href="chap30.html#X858ADA3B7A684421"><span class="RefLink">30.4-6</span></a>) must <em>not</em> call <code class="func">IsFinite</code>.</p>

<p><a id="X7E3402D6799D3C24" name="X7E3402D6799D3C24"></a></p>

<h5>30.4-3 IsTrivial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsTrivial</code>( <var class="Arg">C</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p><code class="func">IsTrivial</code> returns <code class="keyw">true</code> if the collection <var class="Arg">C</var> consists of exactly one element.</p>

<p><a id="X7F192373850B85B9" name="X7F192373850B85B9"></a></p>

<h5>30.4-4 IsNonTrivial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsNonTrivial</code>( <var class="Arg">C</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p><code class="func">IsNonTrivial</code> returns <code class="keyw">true</code> if the collection <var class="Arg">C</var> is empty or consists of at least two elements (see <code class="func">IsTrivial</code> (<a href="chap30.html#X7E3402D6799D3C24"><span class="RefLink">30.4-3</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsEmpty( [] ); IsEmpty( [ 1 .. 100 ] ); IsEmpty( Group( (1,2,3) ) );</span>
true
false
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsFinite( [ 1 .. 100 ] );  IsFinite( Integers );</span>
true
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsTrivial( Integers );  IsTrivial( Group( () ) );</span>
false
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsNonTrivial( Integers );  IsNonTrivial( Group( () ) );</span>
true
false
</pre></div>

<p><a id="X78EF6A137E8F66B0" name="X78EF6A137E8F66B0"></a></p>

<h5>30.4-5 IsWholeFamily</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWholeFamily</code>( <var class="Arg">C</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p><code class="func">IsWholeFamily</code> returns <code class="keyw">true</code> if the collection <var class="Arg">C</var> contains the whole family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>) of its elements.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWholeFamily( Integers )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # all rationals and cyclotomics lie in the family</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWholeFamily( Integers mod 3 )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # all finite field elements in char. 3 lie in this family</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWholeFamily( Integers mod 4 );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWholeFamily( FreeGroup( 2 ) );</span>
true
</pre></div>

<p><a id="X858ADA3B7A684421" name="X858ADA3B7A684421"></a></p>

<h5>30.4-6 Size</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Size</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">Size</code> returns the size of the list or collection <var class="Arg">listorcoll</var>, which is either an integer or <code class="func">infinity</code> (<a href="chap18.html#X8511B8DF83324C27"><span class="RefLink">18.2-1</span></a>). If the argument is a list then the result is its length (see <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>)).</p>

<p>The default method for <code class="func">Size</code> checks the length of an enumerator of <var class="Arg">listorcoll</var>.</p>

<p>Methods for <code class="func">IsFinite</code> (<a href="chap30.html#X808A4061809A6E67"><span class="RefLink">30.4-2</span></a>) may call <code class="func">Size</code>, but methods for <code class="func">Size</code> must not call <code class="func">IsFinite</code> (<a href="chap30.html#X808A4061809A6E67"><span class="RefLink">30.4-2</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Size( [1,2,3] );  Size( Group( () ) );  Size( Integers );</span>
3
1
infinity
</pre></div>

<p><a id="X865507568182424E" name="X865507568182424E"></a></p>

<h5>30.4-7 Representative</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Representative</code>( <var class="Arg">C</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">Representative</code> returns a <em>representative</em> of the collection <var class="Arg">C</var>.</p>

<p>Note that <code class="func">Representative</code> is free in choosing a representative if there are several elements in <var class="Arg">C</var>. It is not even guaranteed that <code class="func">Representative</code> returns the same representative if it is called several times for one collection. The main difference between <code class="func">Representative</code> and <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>) is that <code class="func">Representative</code> is free to choose a value that is cheap to compute, while <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>) must make an effort to randomly distribute its answers.</p>

<p>If <var class="Arg">C</var> is a domain then there are methods for <code class="func">Representative</code> that try to fetch an element from any known generator list of <var class="Arg">C</var>, see <a href="chap31.html#X7E651AC287AFDCC1"><span class="RefLink">31</span></a>. Note that <code class="func">Representative</code> does not try to <em>compute</em> generators of <var class="Arg">C</var>, thus <code class="func">Representative</code> may give up and signal an error if <var class="Arg">C</var> has no generators stored at all.</p>

<p><a id="X8026085680270D37" name="X8026085680270D37"></a></p>

<h5>30.4-8 RepresentativeSmallest</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; RepresentativeSmallest</code>( <var class="Arg">C</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the smallest element in the collection <var class="Arg">C</var>, w.r.t. the ordering <code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>). While the operation defaults to comparing all elements, better methods are installed for some collections.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Representative( Rationals );</span>
0
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Representative( [ -1, -2 .. -100 ] );</span>
-1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">RepresentativeSmallest( [ -1, -2 .. -100 ] );</span>
-100
</pre></div>

<p><a id="X7F8FEA3278239ADE" name="X7F8FEA3278239ADE"></a></p>

<h4>30.5 <span class="Heading">Operations for Collections</span></h4>

<p><a id="X79CA175481F8105F" name="X79CA175481F8105F"></a></p>

<h5>30.5-1 IsSubset</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsSubset</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">IsSubset</code> returns <code class="keyw">true</code> if <var class="Arg">C2</var>, which must be a collection, is a <em>subset</em> of <var class="Arg">C1</var>, which also must be a collection, and <code class="keyw">false</code> otherwise.</p>

<p><var class="Arg">C2</var> is considered a subset of <var class="Arg">C1</var> if and only if each element of <var class="Arg">C2</var> is also an element of <var class="Arg">C1</var>. That is <code class="func">IsSubset</code> behaves as if implemented as <code class="code">IsSubsetSet( AsSSortedList( <var class="Arg">C1</var> ), AsSSortedList( <var class="Arg">C2</var> ) )</code>, except that it will also sometimes, but not always, work for infinite collections, and that it will usually work much faster than the above definition. Either argument may also be a proper set (see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubset( Rationals, Integers );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubset( Integers, [ 1, 2, 3 ] );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubset( Group( (1,2,3,4) ), [ (1,2,3) ] );</span>
false
</pre></div>

<p><a id="X851069107CACF98E" name="X851069107CACF98E"></a></p>

<h5>30.5-2 <span class="Heading">Intersection</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Intersection</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Intersection</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Intersection2</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>In the first form <code class="func">Intersection</code> returns the intersection of the collections <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc. In the second form <var class="Arg">list</var> must be a <em>nonempty</em> list of collections and <code class="func">Intersection</code> returns the intersection of those collections. Each argument or element of <var class="Arg">list</var> respectively may also be a homogeneous list that is not a proper set, in which case <code class="func">Intersection</code> silently applies <code class="func">Set</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>) to it first.</p>

<p>The result of <code class="func">Intersection</code> is the set of elements that lie in every of the collections <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc. If the result is a list then it is mutable and new, i.e., not identical to any of <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc.</p>

<p>Methods can be installed for the operation <code class="func">Intersection2</code> that takes only two arguments. <code class="func">Intersection</code> calls <code class="func">Intersection2</code>.</p>

<p>Methods for <code class="func">Intersection2</code> should try to maintain as much structure as possible, for example the intersection of two permutation groups is again a permutation group.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput"># this is one of the rare cases where the intersection of two</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput"># infinite domains works ('CF' is a shorthand for 'CyclotomicField'):</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( CyclotomicField(9), CyclotomicField(12) );</span>
CF(3)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">D12 := Group( (2,6)(3,5), (1,2)(3,6)(4,5) );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( D12, Group( (1,2), (1,2,3,4,5) ) );</span>
Group([ (1,5)(2,4) ])
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( D12, [ (1,3)(4,6), (1,2)(3,4) ] )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # note that the second argument is not a proper set</span>
[ (1,3)(4,6) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput"># although the result is mathematically a group it is returned as a</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput"># proper set because the second argument is not regarded as a group:</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( D12, [ (), (1,2)(3,4), (1,3)(4,6), (1,4)(5,6) ] );</span>
[ (), (1,3)(4,6) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( Group( () ), [1,2,3] );</span>
[  ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( [2,4,6,8,10], [3,6,9,12,15], [5,10,15,20,25] )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # two or more lists or collections as arguments are legal</span>
[  ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Intersection( [ [1,2,4], [2,3,4], [1,3,4] ] )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # or one list of lists or collections</span>
[ 4 ]
</pre></div>

<p><a id="X799F0E2F7A502DBA" name="X799F0E2F7A502DBA"></a></p>

<h5>30.5-3 <span class="Heading">Union</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Union</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Union</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Union2</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>In the first form <code class="func">Union</code> returns the union of the collections <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc. In the second form <var class="Arg">list</var> must be a list of collections and <code class="func">Union</code> returns the union of those collections. Each argument or element of <var class="Arg">list</var> respectively may also be a homogeneous list that is not a proper set, in which case <code class="func">Union</code> silently applies <code class="func">Set</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>) to it first.</p>

<p>The result of <code class="func">Union</code> is the set of elements that lie in any of the collections <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc. If the result is a list then it is mutable and new, i.e., not identical to any of <var class="Arg">C1</var>, <var class="Arg">C2</var>, etc.</p>

<p>Methods can be installed for the operation <code class="func">Union2</code> that takes only two arguments. <code class="func">Union</code> calls <code class="func">Union2</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Union( [ (1,2,3), (1,2,3,4) ], Group( (1,2,3), (1,2) ) );</span>
[ (), (2,3), (1,2), (1,2,3), (1,2,3,4), (1,3,2), (1,3) ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Union( [2,4,6,8,10], [3,6,9,12,15], [5,10,15,20,25] )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # two or more lists or collections as arguments are legal</span>
[ 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 20, 25 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Union( [ [1,2,4], [2,3,4], [1,3,4] ] )</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   ;  # or one list of lists or collections</span>
[ 1, 2, 3, 4 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Union( [ ] );</span>
[  ]
</pre></div>

<p><a id="X825AC0F07E010B07" name="X825AC0F07E010B07"></a></p>

<h5>30.5-4 Difference</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Difference</code>( <var class="Arg">C1</var>, <var class="Arg">C2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">Difference</code> returns the set difference of the collections <var class="Arg">C1</var> and <var class="Arg">C2</var>. Either argument may also be a homogeneous list that is not a proper set, in which case <code class="func">Difference</code> silently applies <code class="func">Set</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>) to it first.</p>

<p>The result of <code class="func">Difference</code> is the set of elements that lie in <var class="Arg">C1</var> but not in <var class="Arg">C2</var>. Note that <var class="Arg">C2</var> need not be a subset of <var class="Arg">C1</var>. The elements of <var class="Arg">C2</var>, however, that are not elements of <var class="Arg">C1</var> play no role for the result. If the result is a list then it is mutable and new, i.e., not identical to <var class="Arg">C1</var> or <var class="Arg">C2</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Difference( [ (1,2,3), (1,2,3,4) ], Group( (1,2,3), (1,2) ) );</span>
[ (1,2,3,4) ]
</pre></div>

<p><a id="X82D39CF980FDBFFA" name="X82D39CF980FDBFFA"></a></p>

<h4>30.6 <span class="Heading">Membership Test for Collections</span></h4>

<p><a id="X84B7FA8C7C94400F" name="X84B7FA8C7C94400F"></a></p>

<h5>30.6-1 \in</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \in</code>( <var class="Arg">obj</var>, <var class="Arg">C</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the object <var class="Arg">obj</var> lies in the collection <var class="Arg">C</var>, and <code class="keyw">false</code> otherwise.</p>

<p>The infix version of the command</p>

<p><var class="Arg">obj</var> <code class="keyw">in</code> <var class="Arg">C</var></p>

<p>calls the operation <code class="func">\in</code>, for which methods can be installed.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">13 in Integers;  [ 1, 2 ] in Integers;</span>
true
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">g:= Group( (1,2) );;  (1,2) in g;  (1,2,3) in g;</span>
true
false
</pre></div>

<p><a id="X8151A51884B7EE2C" name="X8151A51884B7EE2C"></a></p>

<h4>30.7 <span class="Heading">Random Elements</span></h4>

<p>The method used by <strong class="pkg">GAP</strong> to obtain random elements may depend on the type object.</p>

<p>Most methods which produce random elements in <strong class="pkg">GAP</strong> use a global random number generator (see <code class="func">GlobalMersenneTwister</code> (<a href="chap14.html#X7F772E2686B35865"><span class="RefLink">14.7-4</span></a>)). This random number generator is (deliberately) initialized to the same values when <strong class="pkg">GAP</strong> is started, so different runs of <strong class="pkg">GAP</strong> with the same input will always produce the same result, even if random calculations are involved.</p>

<p>See <code class="func">Reset</code> (<a href="chap14.html#X819E3E3080297347"><span class="RefLink">14.7-3</span></a>) for a description of how to reset the random number generator to a previous state.</p>

<p><a id="X7FF906E57D6936F8" name="X7FF906E57D6936F8"></a></p>

<h5>30.7-1 Random</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Random</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Random</code>( <var class="Arg">from</var>, <var class="Arg">to</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">Random</code> returns a (pseudo-)random element of the list or collection <var class="Arg">listorcoll</var>.</p>

<p>As lists or ranges are restricted in length (<span class="SimpleMath">2^28-1</span> or <span class="SimpleMath">2^60-1</span> depending on your system), the second form returns a random integer in the range <var class="Arg">from</var> to <var class="Arg">to</var> (inclusive) for arbitrary integers <var class="Arg">from</var> and <var class="Arg">to</var>.</p>

<p>The distribution of elements returned by <code class="func">Random</code> depends on the argument. For a list the distribution is uniform (all elements are equally likely). The same holds usually for finite collections that are not lists. For infinite collections some reasonable distribution is used.</p>

<p>See the chapters of the various collections to find out which distribution is being used.</p>

<p>For some collections ensuring a reasonable distribution can be difficult and require substantial runtime (for example for large finite groups). If speed is more important than a guaranteed distribution, the operation <code class="func">PseudoRandom</code> (<a href="chap30.html#X811B5BD47DC5356B"><span class="RefLink">30.7-2</span></a>) should be used instead.</p>

<p>Note that <code class="func">Random</code> is of course <em>not</em> an attribute.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Random([1..6]);</span>
6
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Random(1, 2^100);</span>
866227015645295902682304086250
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">g:= Group( (1,2,3) );;  Random( g );  Random( g );</span>
(1,3,2)
()
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Random(Rationals);</span>
-4
</pre></div>

<p><a id="X811B5BD47DC5356B" name="X811B5BD47DC5356B"></a></p>

<h5>30.7-2 PseudoRandom</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PseudoRandom</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">PseudoRandom</code> returns a pseudo random element of the list or collection <var class="Arg">listorcoll</var>, which can be roughly described as follows. For a list, <code class="func">PseudoRandom</code> returns the same as <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>). For collections that are not lists, the elements returned by <code class="func">PseudoRandom</code> are <em>not</em> necessarily equally distributed, even for finite collections; the idea is that <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>) returns elements according to a reasonable distribution, <code class="func">PseudoRandom</code> returns elements that are cheap to compute but need not satisfy this strong condition, and <code class="func">Representative</code> (<a href="chap30.html#X865507568182424E"><span class="RefLink">30.4-7</span></a>) returns arbitrary elements, probably the same element for each call.</p>

<p><a id="X7EBA01EB83BC65A9" name="X7EBA01EB83BC65A9"></a></p>

<h5>30.7-3 RandomList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; RandomList</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For a dense list <var class="Arg">list</var>, <code class="func">RandomList</code> returns a (pseudo-)random element with equal distribution.</p>

<p>This function uses the <code class="func">GlobalMersenneTwister</code> (<a href="chap14.html#X7F772E2686B35865"><span class="RefLink">14.7-4</span></a>) to produce the random elements (a source of high quality random numbers).</p>

<p><a id="X85A3F00985453F95" name="X85A3F00985453F95"></a></p>

<h4>30.8 <span class="Heading">Iterators</span></h4>

<p><a id="X83ADF8287ED0668E" name="X83ADF8287ED0668E"></a></p>

<h5>30.8-1 Iterator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Iterator</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsStandardIterator</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( filter )</td></tr></table></div>
<p>Iterators provide a possibility to loop over the elements of a (countable) collection or list <var class="Arg">listorcoll</var>, without repetition. For many collections <span class="SimpleMath">C</span>, an iterator of <span class="SimpleMath">C</span> need not store all elements of <span class="SimpleMath">C</span>, for example it is possible to construct an iterator of some infinite domains, such as the field of rational numbers.</p>

<p><code class="func">Iterator</code> returns a mutable <em>iterator</em> <span class="SimpleMath">iter</span> for its argument. If this argument is a list (which may contain holes), then <span class="SimpleMath">iter</span> iterates over the elements (but not the holes) of this list in the same order (see <code class="func">IteratorList</code> (<a href="chap30.html#X858A28667D137C4B"><span class="RefLink">30.8-6</span></a>) for details). If this argument is a collection but not a list then <span class="SimpleMath">iter</span> iterates over the elements of this collection in an unspecified order, which may change for repeated calls of <code class="func">Iterator</code>. Because iterators returned by <code class="func">Iterator</code> are mutable (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>), each call of <code class="func">Iterator</code> for the same argument returns a <em>new</em> iterator. Therefore <code class="func">Iterator</code> is not an attribute (see <a href="chap13.html#X7C701DBF7BAE649A"><span class="RefLink">13.5</span></a>).</p>

<p>The only operations for iterators are <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>), <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>), and <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>). In particular, it is only possible to access the next element of the iterator with <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>) if there is one, and this can be checked with <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>) For an iterator <span class="SimpleMath">iter</span>, <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) returns a mutable iterator <span class="SimpleMath">new</span> that iterates over the remaining elements independent of <span class="SimpleMath">iter</span>; the results of <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>) for <span class="SimpleMath">iter</span> and <span class="SimpleMath">new</span> are equal, and if <span class="SimpleMath">iter</span> is mutable then also the results of <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>) for <span class="SimpleMath">iter</span> and <span class="SimpleMath">new</span> are equal; note that <code class="code">=</code> is not defined for iterators, so the equality of two iterators cannot be checked with <code class="code">=</code>.</p>

<p>When <code class="func">Iterator</code> is called for a <em>mutable</em> collection <span class="SimpleMath">C</span> then it is not defined whether <span class="SimpleMath">iter</span> respects changes to <span class="SimpleMath">C</span> occurring after the construction of <span class="SimpleMath">iter</span>, except if the documentation explicitly promises a certain behaviour. The latter is the case if the argument is a mutable list (see <code class="func">IteratorList</code> (<a href="chap30.html#X858A28667D137C4B"><span class="RefLink">30.8-6</span></a>) for subtleties in this case).</p>

<p>It is possible to have <code class="keyw">for</code>-loops run over mutable iterators instead of lists.</p>

<p>In some situations, one can construct iterators with a special succession of elements, see <code class="func">IteratorByBasis</code> (<a href="chap61.html#X855625D47979005D"><span class="RefLink">61.6-6</span></a>) for the possibility to loop over the elements of a vector space w.r.t. a given basis.</p>

<p>For lists, <code class="func">Iterator</code> is implemented by <code class="func">IteratorList</code> (<a href="chap30.html#X858A28667D137C4B"><span class="RefLink">30.8-6</span></a>). For collections <span class="SimpleMath">C</span> that are not lists, the default method is <code class="code">IteratorList( Enumerator( </code><span class="SimpleMath">C</span><code class="code"> ) )</code>. Better methods depending on <span class="SimpleMath">C</span> should be provided if possible.</p>

<p>For random access to the elements of a (possibly infinite) collection, <em>enumerators</em> are used. See <a href="chap21.html#X7EA3ACE27E43D174"><span class="RefLink">21.23</span></a> for the facility to compute a list from <span class="SimpleMath">C</span>, which provides a (partial) mapping from <span class="SimpleMath">C</span> to the positive integers.</p>

<p>The filter <code class="func">IsStandardIterator</code> means that the iterator is implemented as a component object and has components <code class="code">IsDoneIterator</code> and <code class="code">NextIterator</code> which are bound to the methods of the operations of the same name for this iterator.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">iter:= Iterator( GF(5) );</span>
&lt;iterator&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= [];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">for i in iter do Add( l, i ); od; l;</span>
[ 0*Z(5), Z(5)^0, Z(5), Z(5)^2, Z(5)^3 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">iter:= Iterator( [ 1, 2, 3, 4 ] );;  l:= [];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">for i in iter do</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">     new:= ShallowCopy( iter );</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">     for j in new do Add( l, j ); od;</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   od; l;</span>
[ 2, 3, 4, 3, 4, 4 ]
</pre></div>

<p><a id="X8688C20B828FC129" name="X8688C20B828FC129"></a></p>

<h5>30.8-2 IteratorSorted</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IteratorSorted</code>( <var class="Arg">listorcoll</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">IteratorSorted</code> returns a mutable iterator. The argument must be a collection or a list that is not necessarily dense but whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). It loops over the different elements in sorted order.</p>

<p>For a collection <span class="SimpleMath">C</span> that is not a list, the generic method is <code class="code">IteratorList( EnumeratorSorted( </code><var class="Arg">C</var><code class="code"> ) )</code>.</p>

<p><a id="X87168A827E5B28E4" name="X87168A827E5B28E4"></a></p>

<h5>30.8-3 IsIterator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsIterator</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>Every iterator lies in the category <code class="code">IsIterator</code>.</p>

<p><a id="X8055FC557B5D899E" name="X8055FC557B5D899E"></a></p>

<h5>30.8-4 IsDoneIterator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsDoneIterator</code>( <var class="Arg">iter</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>If <var class="Arg">iter</var> is an iterator for the list or collection <span class="SimpleMath">C</span> then <code class="code">IsDoneIterator( <var class="Arg">iter</var> )</code> is <code class="keyw">true</code> if all elements of <span class="SimpleMath">C</span> have been returned already by <code class="code">NextIterator( <var class="Arg">iter</var> )</code>, and <code class="keyw">false</code> otherwise.</p>

<p><a id="X879F62F77D1D1179" name="X879F62F77D1D1179"></a></p>

<h5>30.8-5 NextIterator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NextIterator</code>( <var class="Arg">iter</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Let <var class="Arg">iter</var> be a mutable iterator for the list or collection <span class="SimpleMath">C</span>. If <code class="code">IsDoneIterator( <var class="Arg">iter</var> )</code> is <code class="keyw">false</code> then <code class="func">NextIterator</code> is applicable to <var class="Arg">iter</var>, and the result is the next element of <span class="SimpleMath">C</span>, according to the succession defined by <var class="Arg">iter</var>.</p>

<p>If <code class="code">IsDoneIterator( <var class="Arg">iter</var> )</code> is <code class="keyw">true</code> then it is not defined what happens when <code class="func">NextIterator</code> is called for <var class="Arg">iter</var>; that is, it may happen that an error is signalled or that something meaningless is returned, or even that <strong class="pkg">GAP</strong> crashes.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">iter:= Iterator( [ 1, 2, 3, 4 ] );</span>
&lt;iterator&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">sum:= 0;;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">while not IsDoneIterator( iter ) do</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">     sum:= sum + NextIterator( iter );</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   od;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsDoneIterator( iter ); sum;</span>
true
10
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ir:= Iterator( Rationals );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l:= [];; for i in [1..20] do Add( l, NextIterator( ir ) ); od; l;</span>
[ 0, 1, -1, 1/2, 2, -1/2, -2, 1/3, 2/3, 3/2, 3, -1/3, -2/3, -3/2, -3, 
  1/4, 3/4, 4/3, 4, -1/4 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">for i in ir do</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">     if DenominatorRat( i ) &gt; 10 then break; fi;</span>
<span class="GAPprompt">&gt;</span> <span class="GAPinput">   od;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">i;</span>
1/11
</pre></div>

<p><a id="X858A28667D137C4B" name="X858A28667D137C4B"></a></p>

<h5>30.8-6 IteratorList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IteratorList</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">IteratorList</code> returns a new iterator that allows iteration over the elements of the list <var class="Arg">list</var> (which may have holes) in the same order.</p>

<p>If <var class="Arg">list</var> is mutable then it is in principle possible to change <var class="Arg">list</var> after the call of <code class="func">IteratorList</code>. In this case all changes concerning positions that have not yet been reached in the iteration will also affect the iterator. For example, if <var class="Arg">list</var> is enlarged then the iterator will iterate also over the new elements at the end of the changed list.</p>

<p><em>Note</em> that changes of <var class="Arg">list</var> will also affect all shallow copies of <var class="Arg">list</var>.</p>

<p><a id="X7DB80BE68271247E" name="X7DB80BE68271247E"></a></p>

<h5>30.8-7 TrivialIterator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; TrivialIterator</code>( <var class="Arg">elm</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>is a mutable iterator for the collection <code class="code">[ <var class="Arg">elm</var> ]</code> that consists of exactly one element <var class="Arg">elm</var> (see <code class="func">IsTrivial</code> (<a href="chap30.html#X7E3402D6799D3C24"><span class="RefLink">30.4-3</span></a>)).</p>

<p><a id="X82677D8F817D6701" name="X82677D8F817D6701"></a></p>

<h5>30.8-8 IteratorByFunctions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IteratorByFunctions</code>( <var class="Arg">record</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">IteratorByFunctions</code> returns a (mutable) iterator <var class="Arg">iter</var> for which <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>), <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>), and <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) are computed via prescribed functions.</p>

<p>Let <var class="Arg">record</var> be a record with at least the following components.</p>


<dl>
<dt><strong class="Mark"><code class="code">NextIterator</code></strong></dt>
<dd><p>a function taking one argument <var class="Arg">iter</var>, which returns the next element of <var class="Arg">iter</var> (see <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>)); for that, the components of <var class="Arg">iter</var> are changed,</p>

</dd>
<dt><strong class="Mark"><code class="code">IsDoneIterator</code></strong></dt>
<dd><p>a function taking one argument <var class="Arg">iter</var>, which returns the <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>) value of <var class="Arg">iter</var>,</p>

</dd>
<dt><strong class="Mark"><code class="code">ShallowCopy</code></strong></dt>
<dd><p>a function taking one argument <var class="Arg">iter</var>, which returns a record for which <code class="func">IteratorByFunctions</code> can be called in order to create a new iterator that is independent of <var class="Arg">iter</var> but behaves like <var class="Arg">iter</var> w.r.t. the operations <code class="func">NextIterator</code> (<a href="chap30.html#X879F62F77D1D1179"><span class="RefLink">30.8-5</span></a>) and <code class="func">IsDoneIterator</code> (<a href="chap30.html#X8055FC557B5D899E"><span class="RefLink">30.8-4</span></a>).</p>

</dd>
<dt><strong class="Mark"><code class="code">ViewObj</code> and <code class="code">PrintObj</code></strong></dt>
<dd><p>two functions that print what one wants to be printed when <code class="code">View( <var class="Arg">iter</var> )</code> or <code class="code">Print( <var class="Arg">item</var> )</code> is called (see <a href="chap6.html#X8074A8387C9DB9A8"><span class="RefLink">6.3</span></a>), if the <code class="code">ViewObj</code> component is missing then the <code class="code">PrintObj</code> method is used as a default.</p>

</dd>
</dl>
<p>Further (data) components may be contained in <var class="Arg">record</var> which can be used by these function.</p>

<p><code class="func">IteratorByFunctions</code> does <em>not</em> make a shallow copy of <var class="Arg">record</var>, this record is changed in place (see Section  <a href="chap79.html#X82E86CF37B123FD4"><span class="RefLink">79.9</span></a>).</p>

<p>Iterators constructed with <code class="func">IteratorByFunctions</code> are in the filter <code class="func">IsStandardIterator</code> (<a href="chap30.html#X83ADF8287ED0668E"><span class="RefLink">30.8-1</span></a>).</p>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap29.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap31.html">[Next Chapter]</a>&nbsp;  </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="http://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>