Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  chap21.html   Sprache: HTML

 

 products/Sources/formale Sprachen/GAP/doc/ref/chap21.html


<?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 21: Lists</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="chap21"  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<<xml="0encoding=UTF-?>

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap20.html">[Previous Chapter]</a>    <a href="chap22.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap21_mj.html">[MathJax on]</a></p>
<p><a id="X7B256AE5780F140A" name="X7B256AE5780F140A"></a></p>
<div class="ChapSects"><a href="chap21.html#X7B256AE5780F140A">21 <span class="Heading">Lists</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X86B28F5B781FFD31">21.1 <span class="Heading">List Categories</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C4CC4EA8299701E">21.1-1 IsList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X870AA9D8798C93DD">21.1-2 IsDenseList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X80872FAF80EB5DF9">21.1-4 IsTable</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79581E0387F7F7A9">21.1-5 IsRectangularTable</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C84E16A85C99C8C">21.1-6 IsConstantTimeAccessList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7B202D147A5C2884">21.2 <span class="Heading">Basic Operations for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8297BBCD79642BE6"><code>21.2-1 <span>\</span>[<span>\</span>]</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7921047F83F5FA28">21.3 <span class="Heading">List Elements</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X78791B8B838A8BA0"><code>21.3-1 \{\}</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8611EF768210625B">21.4 <span class="Heading">List Assignment</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X813FF1637F8D2B7F"><code>21.4-1 \{\}\:\=</code></a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X795EC9D67E34DAB0">21.4-2 Add</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E98B11B79BA9167">21.4-3 Remove</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79D7E96F80A2D7C0">21.4-4 CopyListEntries</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79E31DB27C82D6E1">21.4-5 Append</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7963C8E17EFF86DB">21.5 <span class="Heading">IsBound and Unbind for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79EC565A7DCEC938">21.5-1 IsBound</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X866F45D3797FDA00">21.5-2 GetWithDefault</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X78B72FDF7BD63C0B">21.5-3 Unbind</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7DD65BEA7EDB0CD7">21.6 <span class="Heading">Identical Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7ED7C0738495556F">21.7 <span class="Heading">Duplication of Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X808A207182B2F84F">21.8 <span class="Heading">Membership Test for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B914A287F88ED0A"><code>21.8-1 \in</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X84D6FC7E7E39ED33">21.9 <span class="Heading">Enlarging Internally Represented Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X78BF67A5802E93AD">21.9-1 EmptyPlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8016D50F85147A77">21.10 <span class="Heading">Comparisons of Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X845EEAF083D43CCE">21.11 <span class="Heading">Arithmetic for Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X84D642967B8546B7">21.12 <span class="Heading">Filters Controlling the Arithmetic Behaviour of Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X87ABCEE9809585A0">21.12-1 IsGeneralizedRowVector</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FBCA5B58308C158">21.12-2 IsMultiplicativeGeneralizedRowVector</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7BAD12E67BFC90DE">21.12-3 IsListDefault</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8428E77B86722D52">21.12-4 NestingDepthA</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X84B383B97FD986CD">21.12-5 NestingDepthM</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7E6A1F66781BE923">21.13 <span class="Heading">Additive Arithmetic for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X86A85ADC85C451DC">21.13-1 <span class="Heading">Zero for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B91CE4D814C2D08">21.13-2 <span class="Heading">AdditiveInverse for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X842D123E7EE5E3DB">21.13-3 <span class="Heading">Addition of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C3DC8BE78DEECDE">21.13-4 <span class="Heading">Subtraction of lists</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X782ED7F27D8C7FC1">21.14 <span class="Heading">Multiplicative Arithmetic for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79A8A5627FD42FA5">21.14-1 <span class="Heading">One for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X78C6C1E2849D303A">21.14-2 <span class="Heading">Inverse for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X84FDB95179BFE4CD">21.14-3 <span class="Heading">Multiplication of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X82EA2A5B786181C7">21.14-4 <span class="Heading">Division of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7A0FD70C80B95C00">21.14-5 <span class="Heading">mod for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X84BB2DFB8432A1A4">21.14-6 <span class="Heading">Left quotients of lists</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8676EFE67972FD06">21.15 <span class="Heading">Mutability Status and List Arithmetic</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X80FDB1457FF582E7">21.15-1 ListWithIdenticalEntries</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8196FD4779BCCA0C">21.16 <span class="Heading">Finding Positions in Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79975EC6783B4293">21.16-1 Position</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FA9648883AE1B88">21.16-2 Positions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B4B10AE81602D4E">21.16-3 PositionCanonical</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7D2B25B484591506">21.16-4 PositionNthOccurrence</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7A122E848464E534">21.16-5 PositionSorted</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X820BA44D85930EBF">21.16-6 PositionSortedBy</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X78BFE9D78347C0DA">21.16-7 PositionSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FD9C1D37F300206">21.16-8 PositionMaximum</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E6C763A82C6153B">21.16-9 PositionProperty</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7DA94D278304EC3D">21.16-10 PositionsProperty</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X86C9E5C3863B3C03">21.16-11 PositionBound</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X819F71047AABEA2F">21.16-12 PositionsBound</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X865EF45D87ED1384">21.16-13 PositionNot</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7F42E5AD87EC9D5A">21.16-14 PositionNonZero</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X87A8C62A867D6DA4">21.16-15 PositionSublist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7865747A7CCF5812">21.17 <span class="Heading">Properties and Attributes for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X83F8EC7C7BF27EFC">21.17-1 IsMatchingSublist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FA892828252BB3B">21.17-2 IsDuplicateFree</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7BAA9B0E81D4A884">21.17-3 IsSortedList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X80CDAF45782E8DCB">21.17-4 IsSSortedList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X780769238600AFD1">21.17-5 Length</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B55FB967CDEF468">21.17-6 ConstantTimeAccessList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X83E558E37D1B44D4">21.18 <span class="Heading">Sorting Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FE4975F8166884D">21.18-1 Sort</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X791F2B2C7E9B9A46">21.18-2 SortParallel</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X87287FCA81E2B06A">21.18-3 Sortex</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X800209E881E7CECB">21.18-4 SortingPerm</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X80ABC25582343910">21.19 <span class="Heading">Sorted Lists and Sets</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B16AD597CB12305"><code>21.19-1 \in</code></a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B4C0FEE7CDF6F2A">21.19-2 IsEqualSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X79B940567A849216">21.19-3 IsSubsetSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X832C23CC7FCD8892">21.19-4 AddSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FCA282E789A4F4B">21.19-5 RemoveSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B3469CD7EFC1A87">21.19-6 UniteSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8473AA657FEC3D4D">21.19-7 IntersectSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X80B427537EB07D09">21.19-8 SubtractSet</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7DF510F7848CBBFD">21.20 <span class="Heading">Operations for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X840C55A77D1BB2E1">21.20-1 Concatenation</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7CB0A6AF87C7FAF7">21.20-2 Compacted</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7ECE9056792F28BA">21.20-3 Collected</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8727F2928467C2F9">21.20-4 DuplicateFreeList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7F5D4DD87E4378AC">21.20-5 AsDuplicateFreeList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FA272D984EF82ED">21.20-6 Flat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C4FDB007C3F54A1">21.20-7 Reversed</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8057372F83374193">21.20-8 Shuffle</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8075FBDE7B81B4C8">21.20-9 Apply</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7EF6E2BC81DBF6FB">21.20-10 Perform</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8763882A7D65F979">21.20-11 PermListList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X82CE0DE8828E4303">21.20-12 <span class="Heading">Maximum</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X82F133EC7F89665F">21.20-13 <span class="Heading">Minimum</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X842851EB7E0969F7">21.20-14 <span class="Heading">MaximumList and MinimumList</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E1593B979BDF2CD">21.20-15 <span class="Heading">Cartesian</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E76F5A782184823">21.20-16 <span class="Heading">IteratorOfCartesianProduct</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B5A19098406347A">21.20-17 Permuted</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X86CB7DCE8510F977">21.20-18 List</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7C86D7F7795125F0">21.20-19 Filtered</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8179B13D80E935FC">21.20-20 Number</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X82801DFA84E11272">21.20-21 First</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E5B62E780421CE9">21.20-22 Last</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7F06961278166671">21.20-23 ForAll</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7AF82E747A8BDA75">21.20-24 ForAny</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7E5C72F27B657948">21.20-25 Product</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7A04B71C84CFCC2D">21.20-26 Sum</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X834E4DF57F3A20F0">21.20-27 Iterated</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7D150C2881881139">21.20-28 ListN</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X805CA0B68029B47A">21.21 <span class="Heading">Advanced List Manipulations</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8258477D7F72171B">21.21-1 ListX</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7AC321B87A2DCAF5">21.21-2 SetX</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X82B1411E7FBE925F">21.21-3 SumX</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FB318B47D8783DA">21.21-4 ProductX</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X79596BDE7CAF8491">21.22 <span class="Heading">Ranges</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X86DDC2FF7A50FBEE">21.22-1 IsRange</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X83896BC481536B07">21.22-2 IsRangeRep</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7D22B2298167A58F">21.22-3 ConvertToRangeRep</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7EA3ACE27E43D174">21.23 <span class="Heading">Enumerators</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7BB462C17962647F">21.23-1 IsQuickPositionList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X81ECC2077D88E112">21.24 <span class="Heading">Plain Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X8438CB908367254C">21.24-1 PlainListCopy</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X87BA4EBF80F16B72">21.24-2 IsPlistRep</a></span>
</div></div>
</div>

<h3>21 <span class="Heading">Lists</span></h3>

<p>Lists are the most important way to treat objects together. A <em>list</em> arranges objects in a definite order. So each list implies a partial mapping from the integers to the elements of the list. I.e., there is a first element of a list, a second, a third, and so on. Lists can occur in mutable or immutable form, see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a> for the concept of mutability, and <a href="chap21.html#X7ED7C0738495556F"><span class="RefLink">21.7</span></a> for the case of lists.</p>

<p>This chapter deals mainly with the aspect of lists in <strong class="pkg">GAP</strong> as <em>data structures</em>. Chapter <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a> tells more about the <em>collection</em> aspect of certain lists, and more about lists as <em>arithmetic objects</em> can be found in the chapters <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>.</p>

<p>Lists are used to implement ranges (see <a href="chap21.html#X79596BDE7CAF8491"><span class="RefLink">21.22</span></a>), sets (see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>), strings (see <a href="chap27.html#X7D28329B7EDB8F47"><span class="RefLink">27</span></a>), row vectors and matrices (see <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>, but note that <strong class="pkg">GAP</strong> supports also linear algebra for objects which are <em>not</em> lists, see <a href="chap26.html#X856C23B87E50F118"><span class="RefLink">26</span></a>); boolean lists (see <a href="chap22.html#X7AC531DD79B6938E"><span class="RefLink">22</span></a>) are a further special kind of lists.</p>

<p>Several operations for lists, such as <code class="func">Intersection</code> (<a href="chap30.html#X851069107CACF98E"><span class="RefLink">30.5-2</span></a>) and <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>), will be described in Chapter <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>, in particular see <a href="chap30.html#X7C3722DF8736FFDB"><span class="RefLink">30.3</span></a>.</p>

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

<h4>21.1 <span class="Heading">List Categories</span></h4>

<p>A list can be written by writing down the elements in order between square brackets <code class="code">[</code>, <code class="code">]</code>, and separating them with commas <code class="code">,</code>. An <em>empty list</em>, i.e., a list with no elements, is written as <code class="code">[]</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ];              # a list with three elements</span>
[ 1, 2, 3 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ [], [ 1 ], [ 1, 2 ] ];  # a list may contain other lists</span>
[ [  ], [ 1 ], [ 1, 2 ] ]
</pre></div>

<p>Each list constructed this way is mutable (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>).</p>

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

<h5>21.1-1 IsList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>tests whether <var class="Arg">obj</var> is a list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsList( [ 1, 3, 5, 7 ] );  IsList( 1 );</span>
true
false
</pre></div>

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

<h5>21.1-2 IsDenseList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsDenseList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A list is <em>dense</em> if it has no holes, i.e., contains an element at every position up to the length. It is absolutely legal to have lists with holes. They are created by leaving the entry between the commas empty. Holes at the end of a list are ignored. Lists with holes are sometimes convenient when the list represents a mapping from a finite, but not consecutive, subset of the positive integers.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsDenseList( [ 1, 2, 3 ] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ , 4, 9,, 25,, 49,,,, 121 ];;  IsDenseList( l );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">l[3];</span>
9
<span class="GAPprompt">gap></span> <span class="GAPinput">l[4];</span>
List Element: <list>[4] must have an assigned value
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' after assigning a value to continue
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">l[4] := 16;;  # assigning a value</span>
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">return;       # to escape the break-loop</span>
16
gap>
</pre></div>

<p>Observe that requesting the value of <code class="code">l[4]</code>, which was not assigned, caused the entry of a <code class="keyw">break</code>-loop (see Section <a href="chap6.html#X8593B49F8705B486"><span class="RefLink">6.4</span></a>). After assigning a value and typing <code class="code">return;</code>, <strong class="pkg">GAP</strong> is finally able to comply with our request (by responding with <code class="code">16</code>).</p>

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

<h5>21.1-3 IsHomogeneousList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsHomogeneousList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if <var class="Arg">obj</var> is a list and it is homogeneous, and <code class="keyw">false</code> otherwise.</p>

<p>A <em>homogeneous</em> list is a dense list whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). The empty list is homogeneous but not a collection (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>), a nonempty homogeneous list is also a collection.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHomogeneousList( [ 1, 2, 3 ] );  IsHomogeneousList( [] );</span>
true
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHomogeneousList( [ 1, false, () ] );</span>
false
</pre></div>

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

<h5>21.1-4 IsTable</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsTable</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A <em>table</em> is a nonempty list of homogeneous lists which lie in the same family. Typical examples of tables are matrices (see <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsTable( [ [ 1, 2 ], [ 3, 4 ] ] );    # in fact a matrix</span>
true
< class=GAPprompt"gap&/pan> <span =GAPinput"IsTable([ 1 ] 2, 3  ]);       #rectangularbut java.lang.StringIndexOutOfBoundsException: Range [130, 129) out of bounds for length 136
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsTable<
false
</pre></div>

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

<h5>21.1-5 IsRectangularTable</h5>

<; IsRectangularTable</code>(java.lang.StringIndexOutOfBoundsException: Index 228 out of bounds for length 228
<p>A list lies in <code class="code">IsRectangularTable</codeclass=""< />span class="">&bsp;nbsp;/span>a =chap21.tml#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>

<pspan ""<br/< =nocss>;nbsp;/<ahref".htmlX7C84E16A85C99C8C"java.lang.StringIndexOutOfBoundsException: Range [139, 137) out of bounds for length 148

<h5>21.1-6 IsConstantTimeAccessList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 7
<p>This category indicates whether the access to each element of the list <var class="Arg">list</var> will take roughly the same time. This is implied for example by <code class="code">IsList and IsInternalRep</code>, so all strings, Boolean lists, ranges, and internally represented plain lists are in this category.</p>

<p>div class="ContSSBlock">

<a =X7B202D147A5C2884=X7B202D147A5C2884"/a>/>

<>212 span =Heading>   <span><h4

<>Theoperations are  access ( a =chap21.tmljava.lang.StringIndexOutOfBoundsException: Range [98, 96) out of bounds for length 583

<p>The term basic operation means that each other list operation can be formulated in terms of the basic operations. (But note that often a more efficient method than this one is implemented.)</p>

<p>Any <strong class="pkg">GAP</strong> object <var class="Arg">list</var> in the category <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701Espan class=">br>span class"nocss&bsp;&java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 127

<p>For internally represented lists, kernel methods are provided for the basic list operations with positive integer indices. For other lists or other indices, >java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12

<p><a id="X8297BBCD79642BE6" java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 7

<h5><code>21.2-1 <span>\</span>[<span>\</span>]</code></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227;span"ContSS">br >spanclassnocss"&;;/>a="chap21.html#X78B72FDF7BD63C0B">21.5-3 Unbind</a></span>
<div class="func"><table class="<span>
< class="func">table java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 300
<iv=func">table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Unbind<span>\</span>[<span>\</span>]</code>( <var class="Arg">list</var>, <var class="Arg">ix</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>These operations implement element access, test for element boundedness, list element assignment, and removal of the element with index <var class="Arg">ix</var>.</p>

<p>Note that the special characters <code class="code">[</code>, <code class="code">]</code>, <code class="code">:</code>, and/

<class"ode">[(< class="">list<var,< "Arg"ix>  to <class=code>varclass=Arg"></[< =Arg">ix</></code,which java.lang.StringIndexOutOfBoundsException: Range [211, 206) out of bounds for length 402

<p>Similarly, <code class="func">IsBound<span>\</span>[<span>\</span>]</code> is used explicitly mainly in method installations. In other situations, one can simply call <code class="func">IsBound</code> (<a href="chap21.html#X79EC565A7DCEC938"><span class="RefLink">21.5-1/span>

<>statements codeclass=func>></[span></]\=/>  class""<pan\/>\/java.lang.StringIndexOutOfBoundsException: Range [155, 151) out of bounds for length 165

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

<>. span java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 56

<<class"code>var class"Arg>list</[<var=Arg>ix/var> </>/>

<p>The above construct java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 7


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5, 7, 11, 13 ];;  < class"ContSS">br /<span ""  /span>a href=chap21html#"2112 </a</>
2
3
13
<></

<p>If <var class="Arg">list</var> is not a built-in list, or <var class="span>

<p><code class="code"><var class="Arg">list</var>{ <var class="Arg">poss</var> }</code></p>

<p>The above construct evaluates to a new list <var class="Arg">new</var> whose first element is <code class="code"><var class="Arg">list</var/span


<div class=</div></div>
<div =">span class="tocline"><span class="nocss"> </span><a href="chap21.html#X782ED7F27D8C7FC1">21.14 <span class="Heading"<>
<span class="GAPprompt">gap></span> <span class="GAPinput">l{[4..6]};  l{[1,7,1,8]};</span>
[, 11, 13 java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
[ 2, 17, 2, 19 ]
/></>

<p>The result is aspan>

<p>It is possible to nest such <em>sublist extractions</em>, as can be seen in the example below.</p>


<div class="example"><pre>
<span class=>
[ [ 3, 2 ], [ 6, 5 ], [ 9, 8 ] ]
<divjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 25
[ [ 7, 8, 9 ], [ 4, 5, 6 ] ]
</pre></div>

<p>Note the difference between the two examples. The latter extracts elements 1, 2, and 3 from <>

< =></>]/>or<">{varclass"Arg"poss/var>}</code> we associate a <em>level</em> that is defined as the number of selectors of the form <code class="code">{<var class="Arg">poss</var>}</code> to its left in the same expression. For example</p>


< class""< /<spanclass=nocss>nbsp;&<span<=.X7A122E848464E534"21- />/>
    ]poss2}java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 44
level   0      0      1     2      2     3
//divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<pThena code""< class">/[var "></></of var "java.lang.StringIndexOutOfBoundsException: Range [133, 132) out of bounds for length 459


<div class="example"><pre>
ListElement := function ( list, pos, level )
 if level   
urnp];
 else
  return List( list, elm -> ListElement(elm,pos,level-1) );
 fi;
end;
</pre></divdivclass""><ahref=chap21

< class"


<div class="example"><pre>
ListElements := function ( list, poss, level )
 if level = 0 then
  return list{poss};
  else
   return List( list, elm -> ListElements(elm,poss,level-1) );
  fi;
end;
</pre></div>

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

<h5><code>21.3-1 \{\}</code></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; \{\}</code>( <var class="Arg">list</var>, <var class="Arg">poss</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>This operation implements <em>sublist access<<panclass=C>br >< nocss>nbsp;nbsp;span>< =".html#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>

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

<h4>21.4 <span<span class="ContSS"<>spanclass=nocss>nbsp;n;<span>a href=".html#X7C84E16A85C99C8C">21.1-6 IsConstantTimeAccessList</a></span>

<p><code class"code"<var class="rg>list/var>[<varclass="Arg>ix</var ]: <ar class=Arg">object</var>;</code></p>

p> list   theobject varclass=Arg"object</var> can ofany, to the     =Arg"><var>in the mutable see< href".html


<div class="example"><pre>
<< class="ContSect"< class"">spanclass""&;/>a".html#X7921047F83F5FA28">21.3 <span class="Heading">List Elements</span></a>
spanclass=">&/>< ""l[]: ; l;             
[ 2 ]
<class"ContSSBlock>
[3, 4, 5, 6 ,  ]
spanclass""gapgt;<span>span class="APinput"> : ;         &;indexindex>maybean expression<spanjava.lang.StringIndexOutOfBoundsException: Index 132 out of bounds for length 132
[ 3, [ 4, 5, 6 ], 10 ]
</pre></div>

<p>If the/


<iv "xample>prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<"GAPinput">l4]: entry;l  # <list> is enlarged</span>
[ /span>
< class=G">gapgt</pan>< class="APinput>[10 ]: 1;l;             now&;listgt has a hole<span>
[ 3, [ 4, 5, 6 ], 10, "another entry",,,,,, 1 ]
<></divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<p>The function <code class="func">Add</code> (<a href="chap21.html#X795EC9D67E34DAB0"><span class="RefLink">21.4-2</span></a>) should be used if you want to add an element to the end of the list.</p>

<p><

<p>Ifspanjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

/>

=ContSS>br >sclass=nocss"&&;<span>a href


<<span"ContSS"< >< class=nocss"  /span>ahref"chap21.html#X84B383B97FD986CD">21.12-5 NestingDepthM</a></span>
<panclass"APprompt">></span>spanclass="GAPinput> : [ 2 3,5 11,13 17 19];/>
"GAPprompt">ap><span>< =GAPinput">{1.]}:= 10.]; ;</pan>
[10, 11,12,13, 11, , ,19 
="GAPprompt"gap><span> <class="GAPinput">l{[1,7,1,10]} := [ 1, 2, 3, 4 ];; l;</span>
[ 3, 11, 12, 13, 11, 13, 2, 19,, 4 ]
</pre></div>

<p>The next example shows that it is possible to nest such sublist assignments.</p>


divclass=example"<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<< "">br/>span=nocss>nbsp;nbsp;<span<href=chap21html#X82EA2A5B786181C7">21.14-4 <span class="Heading">Division of lists</span></a>
<span  >br /><span class=nocssass&;spana=chap21.tml
[ [ 1,< class""br/< =ontSS> <=;<> =html#X86DDC2FF7A50FBEE">21.22-1 IsRange</a></span>
</pre></div>

p behaviour


dx">
"java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 139
level   0      0      1     1      1     2
</pre></d=" toclinespan "&bsp;/>ahref"html

< =odevar=list/>[var class=Argvar : varclass=span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7FA892828252BB3B">21.17-2 IsDuplicateFree


d class"">>
ListAssignment := functionp themostimportant  toobjects
 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
  level   then
listo] valsjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 
  classContSS>br<spanclass&;nbsp;span>< chap21html#X800209E881E7CECB">21.18-4 SortingPerm</a></span>
   ListAssignment(h4>
  od;
 fijava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
end;
/>/div>

 codeclass""< =">list<var>< =Arg>poss<var} : varclass"Argvals</var>/  var"levelvar    "" < =Arg"/> var =Arg><var< =Arg>vals/ar>,varclass""level<var><code>  [1 , 3]


>
ListAssignmentsdiv></div>
 local i;
 if<span>
  list{} als;
 else
  for ijava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   ListAssignments( list[i], poss, vals[i], level-1 );
  djava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 fi;
end;
<></div>

<p><a <panjava.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 4

<>code21.1 {}\/java.lang.StringIndexOutOfBoundsException: Range [36, 31) out of bounds for length 37

ivclassfunc< func "%>java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 276
<p>This operation implements sublist assignment. For any list, the default method is to loop over the entries in the list <var class="Arg">poss</var>, and to java.lang.StringIndexOutOfBoundsException: Index 161 out of bounds for length 7

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

<h5>21.4-2 Add</h5>

<div class="func"><table< =C"< />span classspan =GAPprompt>ap&><anjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
<addstheelement varclassArgvartothemutablelist< =">/>.java.lang.StringIndexOutOfBoundsException: Range [100, 99) out of bounds for length 451

<p>The three argument version adds <var class="Arg">obj</var> in position <var class="Arg"java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

pNothing  returned by code class""></code, the functionis onlycalled forits  effect./

p<a  &t;ist&;]have  value

.- </h5>

div=func"<class"func "%>tr=tdleft>code =f">#
<p>java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12

   java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 124

>  form<


<div class="<>that valueofc=java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 446
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5 ];; Add( l, 7 ); l;</span>
class">span""&;/a="html#X7D22B2298167A58F">21.22-3 ConvertToRangeRep</a></span>
="GAPinput"Add(,4,) java.lang.StringIndexOutOfBoundsException: Range [0, 76) out of bounds for length 0
 ,4sclass=</span ==">&<a href"html#X7BB462C17962647F">21.23-1 IsQuickPositionList</a></span>
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 84
4
[2,3,, 7 ]
< >pjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
7
[ 2, 3, 5 ]
 > the  to.A/emobjectsin  .each  apartial   the totheofthelist .,java.lang.StringIndexOutOfBoundsException: Range [215, 214) out of bounds for length 542
[ 2, 3 5java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
</pre></div>

p< id=X79D7E96F80A2D7C0" name=

<h5>21.4-4 <p>Lists are used to implement seejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<div classjava.lang.StringIndexOutOfBoundsException: Range [4, 2) out of bounds for length 216
<p>This function

ods forfor <codeclass""Add<>( =.html#X795EC9D67E34DAB0"><span class="RefLink">21.4-2</span></a>) and <code class="func">Remove</code> (<a href="chap21.html#X7E98B11B79BA9167"><span class="RefLink">21.4-3</span></a>).</p>

<p><a id="X79E31DB27C82D6E1" name="

<h5>21.4-5 Append</h5><</div>

div=func< =func"=100"<>td class=tdleft<pre<>
<>a id"" =""h5.-5 IsRectangularTable<h5

><Alist  code=codeIsRectangularTable<code when isnonemptyandits  are all   java.lang.StringIndexOutOfBoundsException: Range [133, 132) out of bounds for length 169


class=">p> name=X7C84E16A85C99C8C>a</
<spanh5>1.-6IsConstantTimeAccessList<
[dtable" 100>>< =tdleft> =>#java.lang.StringIndexOutOfBoundsException: Index 234 out of bounds for length 234
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 97
[,3  ,11,13,17, java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
</pre></div>

<p><a id="X7963C8E17EFF86DB" name<span class="< are  see =chap21tml#X7921047F83F5FA28"><span class="RefLink">21.3</span></a>), assignment of elements to a list (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>), fetching the length of a list (see <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>)), the test for a hole at a given position, and unbinding an element at a given position (see <a href="chap21.html#X7963C8E17EFF86DB"><span class="RefLink">21.5</span></a>).</p>

<h4>21.5 gap>

 name=X79EC565A7DCEC938></a>/java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<>21.- java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0

class"java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 246
<pjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<ivclass"">pre>
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
true
<<aid= X80872FAF80EB5DF9<java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
false
<pan""gapgt;/sclass">( l101];/java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
false
</pre></div>

<p><a id="X866F45D3797FDA00<<class=>""/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h5>21.5-2 GetWithDefault</h5>

classtdleft"class=unc>8227/>< ""/> java.lang.StringIndexOutOfBoundsException: Range [158, 157) out of bounds for length 283
<p><code class="func">GetWithDefault</code> returns java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

<p>While this method can be used on

<<><p>odeclassc><""><ar class""ar </</>


<div class="example"><java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
"java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
  , "" 
<span class="<p>But also otherenumerators s < 
"a"
spanclass=APprompt"apt<  classGAPinput"etWithDefault(, 2, )</>
2
<span class="GAPprompt">gap></span> <java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
""
<panclass=""gap<pan="gapgt<span span "> : [1,23] [,,] [,89
""
s =GAPprompt>&;/><span/<

<span class="GAPprompt">gap></span><h5>>code>.span><spanjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
false
</pre></div>

p<classf>table=unc %<< < class"&8227; <span>\</span>[<span>\</span>]\:\=</code>( <var class="Arg">list</var>, <var class="Arg">pos</var>, <var class="Arg">ix</var> )</td><td class="tdright">( operation )</td></tr></table></div>

h>.5- <java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22

div=func>java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
>=func><> the   ""n/  mutable var=><.That  of< ""/> <classArglistvar longer  value < java.lang.StringIndexOutOfBoundsException: Range [0, 284) out of bounds for length 0


<div class="example"><pre>
<span
<span if = 
[ ,, 5,7,, 11]
<span class="GAPprompt">gap&/>/iv>
[,2,,7, ]
;

>thatclass""<>(href"hjava.lang.StringIndexOutOfBoundsException: Index 537 out of bounds for length 537

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

h>.6<pan class=Heading> />h4>

<p>With the list assignment (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p


div class="<span class="GAPpromptgap;/><spanclass=GAPinput"m = 12,3], 45,6,[789,[1011java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
: 3;
i :
pheelementjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 465

<p>But in this example it>/> <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


""<>
l := [ 1, 2 ];
l := [< =GAPprompt"<>  < "var=list/>< class""<><>  var=java.lang.StringIndexOutOfBoundsException: Range [126, 125) out of bounds for length 459
<re>div>

psecond changethe ,instead   anew to java.lang.StringIndexOutOfBoundsException: Range [103, 102) out of bounds for length 234


< iflevel = 0then
l := [ 1, 2 ];
l[3] := 3;
</pre></div>

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


>
l1 fi  ""listvardoesnot   list,var =Arg<vardoes evaluate   ,  java.lang.StringIndexOutOfBoundsException: Index 144 out of bounds for length 0
l2 := l1;
l1 := [ 1, ,3]
</

<p>But after the java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0


<div class="example"><pre>
 =  12 java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
l2 =l1
l1[</pre><div
</pre></div>

<p/</>

Letunder two areidentical.<p< class=GAPprompt>></>< =GAPinput>m{[1,2,3]}{[3,2]} := [ [11,12], [13,14], [15,16] ];; m;</span>

pIfenteralistliteral  java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 271


<div class=
l1 := [ 1, 2 otejava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 286
l2 := [ 1, 2 ];
</pre></div<> varclass"><var   a ,< ""<vardoesnottopositiveinteger java.lang.StringIndexOutOfBoundsException: Range [148, 147) out of bounds for length 565

<>infollowing  in   codecode>are./


java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 26
l :  12    .(list java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
forpThenextexample   itisjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 4
</pre></div>

<p>If you assign a list to a variable no new list is created. Thus the list value ofjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 5
l1 := [ 1, 2 ];
l2 := l1;
</pre></div>

<p>If you pass a list as an java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
 =[1,2]
f := function ( l ) return l; end;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
</pre></div>

>    listit    lists  one          the handtwojava.lang.StringIndexOutOfBoundsException: Range [209, 208) out of bounds for length 418


<java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
l1 := [ 1, 2 ];
l2 := l1;
l1[1] := 2;
</pre></div>

pa"Ejava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62

<h4>21.7 <span class="Heading">Duplication of<>  argument formalways  theremoved element.In   <classA"l/ must be empty<>

<>Herewedescribethe  of c class=java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

<p>You maythink that  thefollowing example thesecond assignment the .<p>

>   forany var =Arg"list/> <odeclass"func"ShallowCopy/ (a href"chap12.#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) returns a mutable <em>new</em> list <var class="Arg">new</var> that is <em>not identical</em> to any other list (see <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a>), and whose elements are identical to the elements of <var class="Arg">list</var>.</p>

<p>Analogously, for a <em>mutable</em> list <var class="Arg"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>In both cases/<>

<p><code class="func">ShallowCopy<<>Butafter  following example  list   class=code></>isa name has  changedand thus the value  <code class=code></code> is <class="ode> 1 ,3]/java.lang.StringIndexOutOfBoundsException: Range [205, 204) out of bounds for length 210


<div class="example"><pre>
new := [];
for i in [pWesaythat two lists are emidentical<em> if changing one of them by  listassignment also  the  one This  slightly ,becauseif<em><em>     names <><emlist , correctusagewould be very awkward and  onlyadd    that two listsbeequal  is one  withtwo  names.Thusidentityisanequivalence    arefinement of equality.Identity objects can  detectedusing  classf"java.lang.StringIndexOutOfBoundsException: Range [590, 589) out of bounds for length 683
  if IsBound( list[i] ) then
    new[]=listi;
  fi;
od;
iv


 classexample>>
<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<  in 1.10]do[i : [1 2 ] 
false
spanclassgap<>< =java.lang.StringIndexOutOfBoundsException: Range [76, 60) out of bounds for length 106
true
<span class= , java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
   ,[ 3  ] java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 [ ,  ]
</pre></div>

p""StructuralCopy</ode>(ahref="chap12.html#X7C1E70587EBDD2CB"><span class="RefLink">12.7-2</span></a>) basically executes the following code for lists.</p>


<div class="example"><pre>
new := [];
for 
  if IsBound( list[i] ) then
    new[i] := StructuralCopy( list[i] );
  fi;
od;
</pre></div>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ [ 1, 2 ], [ 3, 4 ] ];;  list2 := StructuralCopy( list1 );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj( list1, list2 );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj( list1[1], list2[1] );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">list2[1][1] := 0;;  list1;  list2;</span>
[ [ 1, 2 ], [ 3, 4 ] ]
[ [ 0, 2 ], [ 3, 4 ] ]
</pre></div>

<p<divclass=""<pre>


="><prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
">gapgt;/span span ="APinput"sub:=[1 2 ];list1 := [ sub, sub ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">list2 := StructuralCopy( list1 );</span>
[ [1 2  ] [1,2 ]
<span class="GAPprompt">gap><
<divclass="example"><pre>
<span class="GAPprompt">gap></span> <spanpa=X7ED7C0738495556Fname"">a<pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
[[1 2 ,[1   java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
</pre></div>

p> id=X808A207182B2F84FnameX808A207182B2F84F"<a</>

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

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

<><>2181 icode/>

<div classcodeclass""><code (a href=chap12.#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) basically executes the following code for lists.</p>
<p>This java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>If the list <var class="java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 26


<div od;
 ="GAPprompt>gap>/span><span class=GAPinput"1in[2, ,1, ;   
true
false
s class  ;
< class=GAPprompt"gap&t<span <span class=GAPinput"IsIdenticalObj list1,java.lang.StringIndexOutOfBoundsException: Range [91, 90) out of bounds for length 100
false
</pre></div>

ref".#X8196FD4779BCCA0C"><span class="RefLink">21.16</span></a>.</p>

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

h49span lass"" InternallyRepresented />4

> ahref

i  1f class"gap/> < class=GAPinput"list21 : ; list1  list2;/>

<p>On the other hand suppose every   <re<iv

<p>So the following strategyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<">>/ span =G"(list1,list2 ;/span>

< <if 

 fine code dealing with plain lists java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 3

<p><a id="X78BF67A5802E93AD" name=

5.1<<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

<div class="func"><table class="func" width="<div class=example"><pre>
<p>Returns: a plain list</p>

divsan class=APpromptgapg;</pan><span =GAPinput"list2: StructuralCopy( list1 );</span>
<p>Returns: nothing</p>

<p>The function <code class="func">[[0  ,[,2  java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

 function< ShrinkAllocationPlist>  <classpkg></trong>s memory manager physical memorywhichisallocatedfor java.lang.StringIndexOutOfBoundsException: Range [185, 180) out of bounds for length 263

<p>Note that therejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example<<a=
<span
[  ]
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
> <span class"GAPinput"># now l uses about 25% more memory than the equal list m</span>
<span class="GAPprompt">gap></span> <span class [12 ], [ , 2  ]
spanclass"GAPprompt"gap></pan><span class=GAPinputjava.lang.StringIndexOutOfBoundsException: Index 112 out of bounds for length 12
</pre></div>

<p><a java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0

<h4>21.10 <span class="Heading

<p><java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p><code class="code"><var<iv java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 4

>  <ar class""list2</varareequalifandonlyif  every index <pan ="SimpleMath"></>,eitherbothentries <var class="Arg">list1</var><span class="SimpleMath">[i]</span> and<pan =GAPpromptgap>/span>< class=GAPinput> in ;# uses binary search and only 4 comparisons</span>


<div class="example"><pre>
<span class="GAPprompt"><>aid"84D6FC7E7E39ED33" name=X84D6FC7E7E39ED33"</a></p>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">[ , 2, 3 ] = [ 1, 2, ];</span>
false
<class""gapgt;/ s class=GAPinput"[ 1,2 3 ]=[3  ]/java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
false
v>

 causeproblems with lists which are java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p><code class="code"><var class="Arg">list1</var> < <var class="Arg">list2</

<p><code class="code"><var class="Arg">list1</var> <= <var class="Arg">java.lang.StringIndexOutOfBoundsException: Range [0, 79) out of bounds for length 0

<>Unboundare  thanboundentry  implies following .   ""<span bethesmallestpositiveinteger<span=SimpleMathi/>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example">p> result thisisof <p>The result of this is of course
<span class="GAPprompt">gap></span> <span class="GAPinput">[pSuppose codeclass=funcLength<><ahrefjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ue
<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rue
<span class="GAPprompt">gap></span> <span class=<div class=func>table java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
true
</pre></div>

p>ote that  comparingtwo  withcclass="code"&;/ <java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 23

<"<a</>

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>It is convenient to have arithmetic operations for listsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>(Due to the intended generality<p>ote that  aresimilar < class=func"EmptyString</ <href"chap27html"< =Rjava.lang.StringIndexOutOfBoundsException: Index 136 out of bounds for length 0

<p>For <divclass="example><pre>

<<spanclass=GAPprompt>ap&t</pan <span =GAPprompt>gap&<span <java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 113

<p>For the definition "gap>/span> span=GPinput"m=EmptyPlist160 iin[1.160 doAdd(,i2) ;<span

<p>For the mutability <span class="APprompt>&;/span < class="GAPinput"># now l uses about 25% more memory than the equal list m</span>

<> details  specialcases  rowvectors and < class=GAPprompt">gap&t;/span>< java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 125

"></</>

<h4>21">  /

<<codeclass=code>varclass="Arg"list1</ar  <class"rg>list2<var</code>/p>

pNote

<p><a id=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h5>21.12-1 IsGeneralizedRowVector</h5>

div<vclassexample""<pre
<p>For a<ivclass="example"><pre>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"< class""<span>< class""> 1,2  ] =[1 2, ;/spanjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
true
false
<span class="GAPprompt">gap></span> <span class="GAPinput">liemat:= LieObject( [ [ 1, 2 ], [ 3, 4 ] ] );</span>
LieObject( [ [ 1, 2 ], [ 3, 4 ] ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">IsGeneralizedRowVector( liemat );</span>
<span =">&;</span> <span =GAPinput> 1 2 3 ] [3 2,1]<spanjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
< definition cause areown such for equality may  toaninfiniterecursion intheif list  to  java.lang.StringIndexOutOfBoundsException: Range [207, 206) out of bounds for length 314

<p><a id="<p><code class="code"><var ""list1<var> &t<classArg"list2/>//p>

<h5>21.12-2 IsMultiplicativeGeneralizedRowVector</h5>

divclass<Lareordered<emlexicographicallyem. entries     entry   the behaviour.Letspanclass""i/span>bethejava.lang.StringIndexOutOfBoundsException: Range [191, 190) out of bounds for length 1003
<p>For a 


<div class="example"><prejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
false
<span class="GAPprompt">gap></span> <span class="GAPinput">< class="">>> <panclass""[ 1,,3 4 ] &;[1 -1  ]   &t;>2 is and lt -1<spanjava.lang.StringIndexOutOfBoundsException: Index 149 out of bounds for length 149
<pNote  forcomparing listswith code =code>;codeor codeclass""<<code, the r)listelements must  comparable < class=java.lang.StringIndexOutOfBoundsException: Range [180, 179) out of bounds for length 499
<span class="GAPprompt">gap></span>pa=X845EEAF083D43CCEname=X845EEAF083D43CCE>/<>
true
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

> that  filters <code class=func>IsGeneralizedRowVector<<> the  flexibility     arequitetechnical.  not toocases matrices see a=chap24.html

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

<h5>21java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

div=func>t =" width"%>tr< => =&8227 /java.lang.StringIndexOutOfBoundsException: Range [128, 127) out of bounds for length 223
>avar=><var,<odeclass="unc><code>indicates java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 0

<p>Fortheofreturnvalues   multiplicativeoperations whose argumentsare  these,see< hrefc.#java.lang.StringIndexOutOfBoundsException: Index 426 out of bounds for length 426

<p>All internally represented lists are in this category, and also all lists in the


<div =example>pre
<span class="GAPprompt
<p<id"java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62

true
< classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
true
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></div>

<p><a id="X8428E77B86722D52" name="java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0

<h5>21.12-4 NestingDepthA<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<div class="func
<java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

<p><a id="X84B383B97FD986CD" LieObject( [ [ 1, 2 ], [ 3, 4 ] ] )

<h5>21.12-5 NestingDepthM</h5>

<>2112- java.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 53
pFora<classpkg><strong object varclass""/><code NestingDepthMcodereturnsthe>depth/><class""obj/>    recursively    spanclass="<>if <varclass""></>  in <codeclassfunc>IsMultiplicativeGeneralizedRowVector<code(a=chap21htmlX7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), as the integer <span class="SimpleMath">1</span> if <var class="Arg">obj</var> is an empty list in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), and as <span class="SimpleMath">1</span> plus the multiplicative nesting depth of the first bound entry in <var class="Arg">obj</var> otherwise.</p>


<div class="example"><pre>
s"java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 109
1
1
class"GAPprompt"gapgt;span><panclass=GAPinput">(m ); ( m )<spanjava.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( liemat );  NestingDepthM( liemat
2
0
<span class="GAPprompt"><< "java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62
class>&;span"">l1) NestingDepthM );</panjava.lang.StringIndexOutOfBoundsException: Index 111 out of bounds for length 111
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l2 );  NestingDepthM( l2 );</span>
1
1
</span=GAPprompt"gapgt<span>

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

<h4>21.13 <span class="Heading">Additive Arithmetic for Lists</span></h4>

< class=GAPprompt"gapgt</><span class="GAPinput">v:= [ 1, 2 ];;  m:= [ v, 2*v ];;</span>

<pjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5

<>aid"X86A85ADC85C451DC" name="86>>/>

<h5>21.13-1 <span class="Heading">Zero for lists</span></h5>

<p>The zero (see <code class="func">Zero</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>)) of a list <span class="SimpleMath">x</span> in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) is defined as the list whose entry at position <span class="SimpleMath">i</span> is the zero of <span class="SimpleMath">x[i]</span> if this entry is bound, and is unbound otherwise.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Zero( [ 1, 2, 3 ] );  Zero( [ [ 1, 2 ], 3 ] );  Zero( liemat );</span>
[ 0, 0, 0 ]
[ [ 0, 0 ], 0 ]
LieObject( [ [ 0, 0 ], [ 0, 0 ] ] )
</pre></div>

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

<h5>21.13-2 <span class="Heading">AdditiveInverse for lists</span></h5>

<p>The additive inverse (see <code class="func">AdditiveInverse</code> </re>div>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span<>< id" =X7FBCA5B58308C158">/>/p>
[ -1, =func> class =%>>td =>""java.lang.StringIndexOutOfBoundsException: Index 246 out of bounds for length 246
  2]
</pre></div>

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

<h5>21.13-3 <span class="Heading"java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<p>If <span class="SimpleMath">x</span> and <span class="SimpleMathp a list var=Argjava.lang.StringIndexOutOfBoundsException: Index 291 out of bounds for length 291

<p>If java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
[ 2,
[ 1, " "java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 62
[ 0*Z(2), 2 ]
          l2:= [ , 2 3 4 5 ;<span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l3java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l1 );  div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func
1
1
<span class="GAPprompt">gap></span> <span<iv ="example"><pre>
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
2
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 + l2;</span>
[ java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<span class="GAPprompt">gap>"APprompt">gt;/><panclass=GAPinput>(l1 ; java.lang.StringIndexOutOfBoundsException: Range [98, 97) out of bounds for length 111
[ [ 2, 2, 3, 4 ],, [ 6, 6, 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l2 + l4;</span>
[ , [ 3, 6, 3, 4,
<span class="GAPprompt">gap></span> <span class="GAPinput">l3 + l4;</span>
 ,2]    , [ 10   java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 + [];</span>
[ 1,, 3, 4 ]
</pre></div>

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

<h5>21.13-4 <span class="Heading">Subtraction of lists</span></h5>

=""GAP" one in="IsGeneralizedRowVector<code>(ahref=chap21html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and the other is also in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) or is neither a list nor a domain, <span class="SimpleMath">x - y</span> is defined as <span class="SimpleMath">x + (-y)</span>.</p>


<div class="java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 12
<span class="GAPprompt"><pTheadditiveinverse ( <code ="unc"AdditiveInverse<code (a href"chap31.html#X84BB723C81D55D63"><span class="RefLink">31.10-9</span></a>)) of a list <span class="SimpleMath">x</span> in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) is defined as the list whose entry at position <span class="SimpleMath">i</span> is the additive inverse of <span class="SimpleMath">x[i]</span> if this entry is bound, and is unbound otherwise.</p>
[ 1, -2, 0, 0, -5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 - l3;</span>
[ [ 0, -2, 3, 4 ],, [ -4, -6, 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l2 - l4;</span>
[ , [ -3, -2, 3, 4, 5 ], [ -5, -4, 3, 4, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l3 - l4;</span>
[ [ 1, 2 ], [ -3, -4 ], [ 0, 0 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 - [];</span>
[ 1,, 3, 4 ]
</pre></div>

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

<h4>21.14 <span class="Heading">Multiplicative Arithmetic for Lists</span></h4>

<p>In this general context, we define the results of multiplicative operations only in the following situations. For unary operations (one and inverse), the unique argument must be in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>); for binary operations (multiplication and division), at least one argument must be in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), and the other either not a list or also in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>).</p>

<p>(For non-list <strong class="pkg">GAP</strong> objects, defining the results of unary operations is not an issue here, and if at least one argument is a list not in <code class="func">IsMultiplicativeGeneralizedRowVector

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

<h5>21.14-1 <span class="Heading">One for lists</span></h5>

<p>The<class=GAPprompt">ap&;/span><span class="APinput">AdditiveInverse ,2 3] ); AdditiveInverse( [ [ 1, 2 ], 3 ] );</span>


<div class="example"><pre>
 class=GAPprompt>gap&t<span spanclass"GAPinput">One([ [ 1 2 ] [3, 4 ;</span>
[ [ 1, 0 ], [ 0, 1 ] ]
<span <h5>21.133 <pan class="eading"Addition of lists</span></h5>
[ [ [ [ 1 ] ], [ [ 0 ] ] ], [ [ [ 0 ] ], [ [ 1 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></<p>If <spanclass"SimpleMath></span>and< class=SimpleMath>y/span arein<code="func>IsGeneralizedRowVector/code>(ahref=chap21.tml#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and have the same additive nesting depth (see <code class="func">NestingDepthA</code> (<a href="chap21.html#X8428E77B86722D52"><span class="RefLink">21.12-4</span></a>)), the sum <span class="SimpleMath">x + y</span> is defined <em>pointwise</em>, in the sense that the result is a list whose entry at position <span class="SimpleMath">i</span> is <span class="SimpleMath">x[i] + y[i]</span> if these entries are bound, is a shallow copy (see <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>)) of <span class="SimpleMath">x[i]</span> or <span class="SimpleMath">y[i]</span> if the other argument is not bound at position <span class="SimpleMath">i</span>, and is unbound if both <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> are unbound at position <span class="SimpleMath">i</span>.</p>

<p><a id="X78C6C1E2849D303A" name="X78C6C1E2849D303A"< >&;/>span=>  ;spanjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

<h5>21.14-2 <span [ ,  , ,4]  , ]

<p>>


divclass="xample">>
<span class="GAPprompt">gap></span> <span class="GAPinput">java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[[-2, 1 ] [ 3/,-1/  java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
</pre></div>

<><a id="X84FDB95179BFE4CDname"X84FDB95179BFE4CD"a>pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>21.14-3 <span class="Heading">Multiplication of lists

<p>There are three possible computations that might be triggered by a java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 0


<dl>
classGAPprompt>gt>s="""ne([[, ][3,]])/spanjava.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
<dd><p>the inner product <span class=    1] ][[0]],[[[0]],   1   ]java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

</dd>
<dt><strong class="Mark">(L)</strong></dt>
<dd><p>the left scalar multiple, i.e., a list whose entry at <>< =X78C6C1E2849D303A" name"X78C6C1E2849D303A"<a>/>


<java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
dd> right multiple,.e,  list entry position< =SimpleMath></span  spanclass="impleMath"x]*y/>if ""x/span>isboundatposition <span class=SimpleMath></span,  isunbound if .<p>

</dd>
</dl>
p>uraim is to generalizethebasic arithmetic of simple  vectors and matrices, so we first summarize the situations that shall be covered.</p>

<div class="pcenter"><table class="GAPDocTable">
<tr>
< class="dcenter>/d>
<td class="tdcenter">scl</td>
<td class="tdcenter">vec</td>
<td java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
</tr>
<tr>
<td class="tdcenter">scl</td>
<td class="tdcenter"><>< class=Mark>I<strong>/
<td class="tdcenter">(L)</td>
<td class"tdcenter"()/d
</tr>
<tr>
class<java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
<td class="java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 5
<td class="tdcenter">(I)</td>
<td ="tdcenter">I)/td>
</tr>
<tr>
<td class="tdcenter">mat</td>
<td class="tdcenter">(R)</td>
<td class="tdcenter">(R)</td>
<td class="tdcenter">(R)</td>
</tr>
</table><br />
</div>

Thismeans for   a()avector()  (    L  that isjava.lang.StringIndexOutOfBoundsException: Range [158, 157) out of bounds for length 162

<p>Now we can state the general multiplication rules.</p>

<p>If exactly one argument is in <code class="func"< =>)/java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

<p>In the remaining cases,td class""()/>

<p>So <> >

<>If  argumenthasodd depthis a  has depthandjava.lang.StringIndexOutOfBoundsException: Range [138, 135) out of bounds for length 305

<p>We are left with the case that each argument has even multiplicative nesting depth. If


<div class<
">gap;<span span class="GAPinput">[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ] * (1,4);</span>
[ (1,4), (1,4)(2,3), (1,2,4), (1,2,3,4), (1,3,2,4), (1,3,4) ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, , 4 ] * 2;</span>
[ 2, 4,, 8 ]
span="GAPprompt"gap spanclass=GAPinput> 1 2,3]* [ 1, 3, 5, 7]/span>
22
<span class="GAPprompt">gap></span> <span class="GAPinput">m:= [ [ 1, 2 ]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ,,[[3  ,9]]
<span class="GAPprompt">gap></span> <span class="GAPinput">m * m = [ m[1,,,)]
true
<<panclass"gapgt;/><pan =GAPinput"[1 , , 4 ] *2<span>
14
<java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
true
</pre></div>

<p><a id="X82EA2A5B786181C7spanclass=GAPprompt>gt;<span> <pan class="GAPinput"> *m = [ [1  m,m[2 *m </java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100

<h5>21.14-4 <span class="Heading">Division14

<p>For#X7FBCA5B58308C158


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ] /
[ 1/2, 1, 1/, 1,3/ java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
[ 1, 0 ]
</pre></div>

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

<h5>21.14-5 <span class="Heading">mod for lists</span></h5>

<p>If <var class="Arg">x</var> and <var class="Arg">y</var> are in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and have the same multiplicative nesting depth (see <code class="func">NestingDepthM</code> (<a href="chap21.html#X84B383B97FD986CD"><span class="RefLink">21.12-5</span></a>)), <code class="code"><var class="Arg">x</var> mod <var class="Arg">y</var></code> is defined <em>pointwise</em>, in the sense that the result is a list whose entry at position <span class="SimpleMath">i</span> is <code class="code"><var class="Arg">x</var>[i] mod <var class="Arg">y</var>[i]</code> if these entries are bound, is a shallow copy (see <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>)) of <span class="SimpleMath">x[i]</span> or <span class="SimpleMath">y[i]</span> if the other argument is not bound at position <span class="SimpleMath">i</span>, and is unbound if both <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> are unbound at position <span class="SimpleMath">i</span>.</p>

<p>If <span class="SimpleMath">x</span> is in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and <span class="SimpleMath">y</span> is in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and has lower multiplicative nesting depth or is neither a list nor a domain, <code class="code"><var class="Arg">x</var> mod <var class="Arg">y</var></code> is defined as a list whose entry at position <span class="SimpleMath">i</span> is <code class="code"><var class="Arg">x</var>[i] mod <var class="Arg">y</var></code> if <var class="Arg">x</var> is bound at position <span class="SimpleMath">i</span>, and is unbound if not. The equivalent holds in the reversed case, where the order of the arguments is kept.</p>g/java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 103


<div class="example"><pre>
spanGAPpromptgapgt<span span=""> mod[2 3,5  ;/>
[ 1, 1,, 1, 0 ]
<span class="GAPprompt">gap></span> <span class<pan class=GAPprompt>&;/><class=GAPinput"P( ,IsPrimeInt )</>
[ 2, 0, 1, 2, 0 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 10, 12, 14, 16 ] mod [ 3, 5, 7 ];</span>
[ 1, 2, 0, 16 ]
</pre></div>

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

<h5>21.14-6 <span class="Heading">Left quotients of lists</span></h5>

<p>For two <<>aid"X86C9E5C3863B3C03"=X86C9E5C3863B3C03</a<p>


<div class="example"><pre>
<span class="GAPprompt">gap>< ="unc"< ""width=100%>tr< class"">code=func&8227; PositionBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
[ 0, 1/2 ]
</pre></div>

<p><a id="X8676EFE67972FD06" name=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h4>21.15 <span class="Heading">Mutability Status and List Arithmetic</span></h4>

<p>Manyresults ,    lists,are  lists,  is  whethertheir entriesare ornot (f).Note that the mutability  of the  itselfis  by general rule  any result of anarithmetic,notonly  see< href".java.lang.StringIndexOutOfBoundsException: Range [404, 359) out of bounds for length 404

<p><span class"; class""java.lang.StringIndexOutOfBoundsException: Range [77, 75) out of bounds for length 93

<p>Thus a fully mutable matrix

<p>The immutability level of the result of any of the binary operations discussed here is the minimum of the immutability levels of the argumentsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Moreover,<div "func"table"func"width100>tr< java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 224

div class=>pre

<p>For example, the sum of< ""gapgt/ spanGjava.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 93

<p>For unaryjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2


"><prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
>gap<> spanclass">IsMutable );IsMutable(2  ( 1, 2 3] ))<span>
true
false
<span lass=""<table =func 100%<>"java.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 281
true
true
<<div>

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

<p><a id="X80FDB1457FF582E7" <h5>21.16-14 PositionNonZero</h5>

.1h5

<div class="func"><table class="func" width="100%"><tr>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListWithIdenticalEntries( 10, 0 );</span>
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
</pre></div>

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

<h4>21.16 <span class="Heading">Finding Positions in Lists</span></h4>

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

<h5>21.16-1 Position</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; Position</code>( <var class="Arg">list</var>, <var class="Arg">obj</var>[, <var class="Arg">from</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the position of the first occurrence <var class="Arg">obj</var> in <var class="Arg">list</var>, or <code class="keyw">fail</code> if <var class="Arg">obj</var> is not contained in <var class="Arg">list</var>. If a starting index <var class="Arg">from</var> is given, it returns the position of the first occurrence starting the search <em>after</em> position <var class="Arg">from</var>.</p>

<java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Position( [ 2, 2, 1, 3 ], 1 );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">
2
<span class="GAPprompt">gap></span> <span class="GAPinput">Position( [ 2, 1, 1, 3 ], 1, 2 );</span>
3
< classGAPprompt">></span><class=GAPinput"Position([ 2,1 1  , 1 3 )
fail
</pre></div>

<

<h5>21.16-2 Positions</h5>

<div class="func"><table class="funcjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<p>returns the set of positions of <em>all</em> occurrences of <var class="Arg">obj</var> in <var class=java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1


<">prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<<pcode="<>a"#java.lang.StringIndexOutOfBoundsException: Index 315 out of bounds for length 315
,  ]
<span class="GAPprompt">gap></span> <java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 33
[  ]
<div

paid=X7B4B10AE81602D4E =X7B4B10AE81602D4E"></a></p>

<h5>21.16-3 PositionCanonical</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionCanonical</code>( <var class="Arg">list</var>, <var class="Arg">obj</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returnsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

ForcodefuncRcode(hrefhtml


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">g:=Group((1,2,3,4),(1,2));;u:=Subgroup(g,[(1,2)(3,4),(1,3)(2,4)]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">rt:=RightTransversal(g,u);;AsList(rt);</span>
[ (), (3,4), (2,3), (2,3,4), (2,4,3), (2,4) ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Position(rt,(1,2));</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionCanonical(rt,(1,2));</span>
2
</pre></div>

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

<h5>21.16-4 PositionNthOccurrence</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionNthOccurrence</code>( <var class="Arg">list</var>, <var class="Arg">obj</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the position of the <var class="Arg">n</var>-th occurrence of <var class="Arg">obj</var> in <var class="Arg">list</var> and returns <code class="keyw">fail</code> if <var class="Arg">obj</var> does not occur <var class="Arg">n</var> times.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNthOccurrence([1,2,3,2,4,2,1],1,1);</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNthOccurrence([1,2,3,2,4,2,1],1,2);</span>
7
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNthOccurrence([1,2,3,2,4,2,1],2,3);</span>
6
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNthOccurrence([1,2,3,2,4,2,1],2,4);</span>
fail
</pre></div>

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

<h5>21.16-5 PositionSorted</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionSorted</code>( <var class="Arg">list</var>, <var class="Arg">elm</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Called with two arguments, <code class="func">PositionSorted</code> returns the position of the element <var class="Arg">elm</var> in the sorted list <var class="Arg">list</var>.</p>

<p>Called with three arguments, <code class="func">PositionSorted</code> returns the position of the element <var class="Arg">elm</var> in the list <var class="Arg">list</var>, which must be sorted with respect to <var class="Arg">func</var>. <var class="Arg">func</var> must be a function of two arguments that returns <code class="keyw">true</code> if the first argument is less than the second argument, and <code class="keyw">false</code> otherwise.</p>

<p><code class="func">PositionSorted</code> returnsjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

p="codebinary search  codeclass"><code a=

<p>Developers who wish to adapt this for custom list types need to install suitable methods for the operation <code class="code">PositionSortedOp</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSorted( [1,4,5,5,6,7], 0 );</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSorted( [1,4,5,5,6,7], 2 );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSorted( [1,4,5,5,6,7], 4 );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSorted( [1,4,5,5,6,7], 5 );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSorted( [1,4,5,5,6,7], 8 );</span>
7
</pre></div>

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

<h5>21.16-6 PositionSortedBy</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionSortedBy</code>( <var class="Arg">list</var>, <var class="Arg">val</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns the same value that would be returned by <code class="code">PositionSorted(List(list, func), val)</code>, but computes it in a more efficient way.</p>

<p>To be more precise, <var class="Arg">func</var> must be a function on one argument which returns values that can be compared to <var class="Arg">val</var>, and <var class="Arg">list</var> must be a list for which <code class="code">func(list[i]) <= func(list[i+1])</code> holds for all relevant <var class="Arg">i</var>. This property is not verified, and if the input violates it, then the result is undefined.</p>

<p><code class="func">PositionSortedBy</code> returns <var class="Arg">pos</var> such that <span class="SimpleMath"><var class="Arg">func</var>(<var class="Arg">list</var>[<var class="Arg">pos</var>-1]) < <var class="Arg">val</var> ≤ <var class="Arg">func</var>(<var class="Arg">list</var>[<var class="Arg">pos</var>])</span> holds. That means, if there are elements <code class="code">elm</code> in <var class="Arg">list</var> for which <<p><code class="func">PositionSortedBy</code> returns <var class="Arg">pos</var> such that <span class="SimpleMath"><var class="Arg">func</var>(<var class="Arg">list</var>[<var class="Arg">pos</var>-1]) < <var class="Arg">val</var> ≤ <var class="Arg">func</var>(<var class="Arg">list</var>[<var class="Arg">pos</var>])</span> holds. That means, if there are elements <code class="code">elm</code> in <var class="Arg">list</var> for which <span

<p><code class="func">PositionSortedBy</code> uses java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Developers who wish to adapt this <>setof those positions in  <classArg><var  boundfor    var""f<  code">/><p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", <pan class=GAPprompt"gap;/pan> span class="APinput"PositionsProperty(l  ;/>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], 0, Length );</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], 1, Length );</span>
2/>/div>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], 2, Length );</span>
2
<span class="GAPprompt">gap></span> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
3
</pre></div>

<p>

<h5>21.16-7 PositionSet</h5>

<div class="func"><java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
<p><code class="func">PositionSet</< class="GAPprompt">apgt</pan <panclass="APinput">PositionBound([1,2,3]);</span>


divjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 26
<span class="java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
fail
<span class="GAPprompt">gapjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSet( [1,4,5,5,6,7], 4 );</span<h5>21.16-12 PositionsBound</h5>
2
<span class="GAPprompt">gap></span> <span class=<div class"func"<tableclass""width100"><r<td =tdleft"< =func"‣ PositionsBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
3
<span <p>returns theset ofall positions  the list <ar =Arg><var./>
fail
</pre></div>

<p>spanG>&;/span <panclass"APinput"PositionsBound,,3)<span>

h5>.- <h5

<div class="func"><tablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="func"><table classh5211613
p  position  maximum (< =func"PositionMaximum/)orminimum withcode ="">PositionMinimum<code>  inthe < class=Arg"list/. If  argument  class"">func/  passed return insteadthe  thelargest/mallestentry</var> )/.Ifentries the areequalto minimum, the first such position is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionMaximum( [2,4,-6,2,4] );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionMaximum( [2,4,-6,2,4], x -&p&gt;For   < class=Arg><var and  object < =Arg>val</> codeclass=func>PositionNot<code  the  nonnegative  <pan ="impleMath"n/>such that< "SimpleMath>varclass"Arg"list/[n]/>iseither tov "><var.If   <arclassA"from/>is , returns  firstposition this  startingthe  emafter/>  var =Arg>rom<var>./java.lang.StringIndexOutOfBoundsException: Index 515 out of bounds for length 515
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionMinimum( [2,4,-6,2,4] );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionMinimum( [2,4,-6
2
/>/>

<p><code class="func< "gap<<">java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 117

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

<h5>21.16-9 PositionProperty

<div class="func"><table class="funcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>returns the position of the first entry in the list <var class="Arg">list</var> for which the property tester function <var class="Arg">func</var> returns <code class="keyw">true</code>, or <code class="keyw">fail</code> if no such entry exists. If a starting index <var class="Arg">from</var> is given, it returns the position of the first entry satisfying <var class="Arg">java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


< =example><re>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionProperty( [10^7..10^8], IsPrime );</span>
20
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionProperty( [10^5..10^6],</span>
<span class="GAPprompt">></span> <span class="GAPinput">       n -> not IsPrime(n) and IsPrimePowerInt(n) );</span>
490
</pre></div>

<p><code class="func">First</code> (<a href="chap21.html#X82801DFA84E11272"><span class="RefLink">21.20-21</span></a>) allows you to extract the first element of a list that satisfies a certain property.</p>

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

h5.-10PositionsProperty<h5

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionsProperty</code>( <var class="Arg">list</var>, <var class="Arg">func</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the set of all those positions in the list <var class="Arg">list</var> which are bound and for which the property tester function <var class="Arg">func</var> returns <code class="keyw">true</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ -5 .. 5 ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionsProperty( l, IsPosInt );</span>
[ 7, 8, 9, 10, 11 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionsProperty( l, IsPrimeInt );</span>
[ 1, 3, 4, 8, 9, 11 ]
</pre></div>

<p><code class="func">PositionProperty</code> (<a href="chap21.html#X7E6C763A82C6153B"><span class="RefLink">21.16-9</span></a>) allows you to extract the position of the first element in a list that satisfies a certain property.</p>

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

<h5>21.16-11 PositionBound</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the first bound position of the list <var class="Arg">list</var>. For the empty list it returns <code class="keyw">fail</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionBound([1,2,3]);</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionBound([,1,2,3]);</span>
2
</pre></div>

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

<h5>21.16-12 PositionsBound</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionsBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all bound positions in the list <var class="Arg">list</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionsBound([1,2,3]);</span>
[ 1 .. 3 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionsBound([,1,,3]);</span>
[ 2, 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionsBound([]);</span>
[]
</pre></div>

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

<h5>21.16-13 PositionNot</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PositionNot</code>( <var class="Arg">list</var>, <var class="Arg">val</var>[, <var class="Arg">from</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>For a list <var class="Arg">list</var> and an object <var class="Arg">val</var>, <code class="func">PositionNot</code> returns the smallest nonnegative integer <span class="SimpleMath">n</span> such that <span class="SimpleMath"><var class="Arg">list</var>[n]</span> is either unbound or not equal to <var class="Arg">val</var>. If a starting index <var class="Arg">from</var> is given, it returns the first position with this property starting the search <em>after</em> position <var class="Arg">from</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ 1, 1, 2, 3, 2 ];;  PositionNot( l, 1 );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNot( l, 1, 4 );  PositionNot( l, 2, 4 );</span>
5
6
</pre></div>

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

<h5>21.16-14 PositionNonZero</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PositionNonZero</code>( <var class="Arg">vec</var>[, <var class="Arg">from</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>For a row vector <var class="Arg">vec</var>, <code class="func">PositionNonZero</code> returns the position of the first non-zero element of <var class="Arg">vec</var>, or <code class="code">Length(</code> <var class="Arg">vec</var> <code class="code">)+1</code> if all entries of <var class="Arg">vec</var> are zero.</p>

<p>If a starting index <var class="Arg">from</var> is given, it returns the position of the first occurrence starting the search <em>after</em> position <var class="Arg">from</var>.</p>

<p><code class="func">PositionNonZero</code> implements a special case of <code class="func">PositionNot</code> (<a href="chap21.html#X865EF45D87ED1384"><span class="RefLink">21.16-13</span></a>). Namely, the element to be avoided is the zero element, and the list must be (at least) homogeneous because otherwise the zero element cannot be specified implicitly.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNonZero( [ 1, 1, 2, 3, 2 ] );</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNonZero( [ 2, 3, 4, 5 ] * Z(2) );</span>
2
</pre></div>

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

<521.- h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PositionSublist</code>( <var class="Arg">list</var>, <var class="Arg">sub</var>[, <var class="Arg">from</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the smallest index in the list <var class="Arg">list</var> at which a sublist equal to <var class="Arg">sub</var> starts. If <var class="Arg">sub</var> does not occur the operation returns <code class="keyw">fail</code>. The version with given <var class="Arg">from</var> starts searching <em>after</em> position <var class="Arg">from</var>.</p>

<p>To determine whether <var class="Arg">sub</var> matches <var class="Arg">list</var> at a particular position, use <code class="func">IsMatchingSublist</code> (<a href="chap21.html#X83F8EC7C7BF27EFC"><span class="RefLink">21.17-1</span></a>) instead.</p>

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

<h4>21.17 <span class="Heading">Properties and Attributes for Lists</span></h4>

<p>A list that contains mutable objects (like lists or records) <em>cannot</em> store attribute values that depend on the values of its entries, such as whether it is homogeneous, sorted, or strictly sorted, as changes in any of its entries could change such property values, like the following example shows.</p>


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

<p>For such lists these property values must be computed anew each time the property is asked for. For example, if <var class="Arg">list</var> is a list of mutable row vectors then the java.lang.StringIndexOutOfBoundsException: Index 189 out of bounds for length 0

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

<h5>21.17-1 IsMatchingSublist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><java.lang.StringIndexOutOfBoundsException: Range [0, 79) out of bounds for length 12
<p>returns <code class="keyw">true</code> if <var class="Arg

<p>If you actually want to know whether there is an <var class="Arg">at</var> for which <code class="code">IsMatchingSublist( <var class="Arg">list</var>, <var class="div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PositionSublist</code>( <var class="Arg">list</var>, <var class="Arg)td>tclasst"(nbsp;perationnbsp;)/d<t>/>/>

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

<h5>21.17-2 IsDuplicateFree</h5>

<div class
<div class="func"><table java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
<p><code class="func">IsDuplicateFree</code> returns <code class="keyw">true</code> if <var class="Arg">obj</var> is both a list or collection, and it is duplicate free; otherwise it<> list that contains mutable objects (like lists or records) <em>cannot</em> store attribute values that depend on the values of its entries, such as whether it is homogeneous, sorted, or strictly sorted, as changes in any of its entries could change such property values, like the following example shows.</p>

  <if it   and does notcontain entries differentpositions.   ( a href=".tml#">span class="12.4/pan<a) is  free./>

<p>Note that <strong class="pkg">GAP</strong> cannot compare arbitrary objects (by equality). This can cause that <code class="func">java.lang.StringIndexOutOfBoundsException: Index 148 out of bounds for length 86

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

<h5>21.17-3 IsSortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsSortedList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if <var class="Arg">obj</var> is a list and it is sorted, and <code class="keyw">false</code> otherwise.</p>

<p>A list <var class="Arg">list</var> is <em>sorted</em> if it is dense (see <code class="func">IsDenseList</code> (<a href="chap21.html#X870AA9D8798C93DD"><span class="RefLink">21.1-2</span></a>)) and satisfies the relation <span class="SimpleMath"><var class="Arg">list</var>[i] ≤ <var class="Arg">list</var>[j]</span> whenever <span class="SimpleMath">i < jjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Many sorted lists are in fact homogeneous (see <code class="func">IsHomogeneousList</code> (<a href="chap21.html#X7C71596C82B6EF35"><span class="RefLink">21.1-3</span></a>)), but also non-homogeneous lists may be sorted (see <a href="chap31.html#X7B3BC7BA7BB2646D"><span java.lang.StringIndexOutOfBoundsException: Index 278 out of bounds for length 0

<p>In sorted lists, membership test and computing of positions can be done by binary search, see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>.</p>

<p>Note that <strong class="pkg">GAP</strong> cannot compare (by less than) arbitrary objects. This can cause that <code class="func">IsSortedList</code> runs into an error, if <var class="Arg">obj</var> is a list with some non-comparable entries.</p>

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

<h5>21.17-4 IsSSortedList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsSSortedList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsSet</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if <var class="Arg">obj</var> is a list and it is strictly sorted, and <code class="keyw">false</code> otherwise. <code class="func">IsSSortedList</code> is short for <q>is strictly sorted list</q>; <code class="func">IsSet</code> is just a synonym for <code class="func">IsSSortedList</code>.</p>

<p>A list <var class="Arg">list</var> is <em>strictly sorted</em> if it is sorted (see <code class="func">IsSortedList</code> (<a href="chap21.html#X7BAA9B0E81D4A884"><span class="RefLink">21.17-3</span></a>)) and satisfies the relation <span class="SimpleMath"><var class="Arg">list</var>[i] < <var class="Arg">list</var>[j]</span> whenever <span class="SimpleMath">i < j</span>. In particular, such lists are duplicate free (see <code class="func">IsDuplicateFree</code> (<a href="chap21.html#X7FA892828252BB3B"><span class="RefLink">21.17-2</span></a>)).</p>

<p>(Currently there is little special treatment of lists that are sorted but not strictly sorted. In particular, internally represented lists will <em>not</em> store that they are sorted but not strictly sorted.)</p>

<p>Note that <strong class="pkg">GAP</strong> cannot compare (by less than) arbitrary objects. This can cause that <code class="func">IsSSortedList</code> runs into an error, if <var class="Arg">obj</var> is a list with some non-comparable entries.</p>

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

<h5>21.17-5 Length</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Length</code>( <var class="Arg">list</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the <em>length</em> of the list <var class="Arg">list</var>, which is defined to be the index of the last bound entry in <var class="Arg">list</var>.</p>

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

<h5>21.17-6 ConstantTimeAccessList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ConstantTimeAccessList</code>( <var class="Arg">list</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">ConstantTimeAccessList</code> returns an immutable list containing the same elements as the list <var class="Arg">list</var> (which may have holes) in the same order. If <var class="Arg">list</var> is already a constant time access list, <code class="func">ConstantTimeAccessList</code> returns an immutable copy of <var class="Arg">list</var> directly. Otherwise it puts all elements and holes of <var class="Arg">list</var> into a new list and makes that list immutable.</p>

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

<h4>21.18 <span class="Heading">Sorting Lists</span></h4>

<p>GAP implements three different families of sorting algorithms. The default algorithm is pattern-defeating quicksort, a variant of quicksort which performs better on partially sorted lists and has good worst-case behaviour. The functions which begin <code class="code">Stable</code> are stable (equal elements keep the same relative order in the sorted list) and use merge sort. Finally, the functions which begin <code class="code">Shell</code> use the shell sort which was GAP's default search algorithm before 4.9. <code class="func">Sortex</code> (<a href="chap21.html#X87287FCA81E2B06A"><span class="RefLink">21.18-3</span></a>) and <code class="func">SortingPerm</code> (<a href="chap21.html#X800209E881E7CECB"><span class="RefLink">21.18-4</span></a>) are also stable.</p>

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

<h5>21.18-1 Sort</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Sort</code>( <var class="Arg">list</var>[, <var class="Arg">func</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">&#an style='color: green'>8227; SortBy</code>( <var class="Arg">list</var>, <var class="Arg">func</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">&#an style='color: green'>8227; StableSort</code>( <var class="Arg">list</var>[, <var class="Arg">func</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">&#an style='color: green'>8227; StableSortBy</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">Sort</code> sorts the list <var class="Arg">list</var> in increasing order. In the one argument form <code class="func">Sort</code> uses the operator <code class="code"><</code> to compare the elements. (If the list is not homogeneous it is the user's responsibility to ensure that <code class="code"><</code> is defined for all element pairs, see <a href="chap31.html#X7B3BC7BA7BB2646D"><span class="RefLink">31.11</span></a>) In the two argument form <code class="func">Sort</code> uses the function <var class="Arg">func</var> to compare elements. <var class="Arg">func</var> must be a function taking two arguments that returns <code class="keyw">true</code> if the first is regarded as strictly smaller than the second, and <code class="keyw">false</code> otherwise.</p>

<p><code class="func">StableSort</code> behaves identically to <code class="func">Sort</code>, except that <code class="func">StableSort</code> will keep elements which compare equal in the same relative order, while <code class="func">Sort</code> may change their relative order./<<java.lang.StringIndexOutOfBoundsException: Range [188, 187) out of bounds for length 251

<p><code class="func">Sort</code> does not return anything, it just changes the argument <var class="Arg">list</var>. Use <code class="func">ShallowCopy</code> (<a href="chap12.

< the list <var "">list</ar an suchthat<ode =">unc(list[] lt; func([+

<<ode =func"<code>  the same  <ode class">ortBy/>  that < =">StableSort/,it  pairsofvalues which compare equalwhen <code =code"func<code>is appliedto themin the same  order./p>


<div class="example"><pre>
<span class="GAPprompt[9<GAP three  families of  algorithms    ispattern-defeatingquicksort   ofquicksortwhich   on partiallysorted lists   good worst-case behaviour.Thefunctionswhich begin <class"ode"Stable/>  e   the same relative order the  )anduse merge  java.lang.StringIndexOutOfBoundsException: Range [389, 388) out of bounds for length 781
[ 1, 4, 5, 5, 6, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">SortBy(list, x -> x mod 3);<
<span class="GAPprompt">gap></span> <span class<p<a id=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[6,,,7,5, ]
<span class="GAPprompt">gap></span> <span class="GAPinput">list := [ [0,6], [1,2], [1,3], [1,5], [0,4], "<div class="func
< =GAPprompt">gt/span> spanclass">  v,)>#;StableSortBycode ar rglist/> < "Arg">var <t> ="bjava.lang.StringIndexOutOfBoundsException: Range [229, 228) out of bounds for length 254
< =">&< <pan =java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 131
[  ,2 ,[ 1 3] [, ],[3 4, ,,4  , ,11java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
<span class="GAPprompt">gap&pre<div>
<span class="java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 0
[ java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<span class="GAPprompt">gap></span> <span class="GAPinput">Sort( list, function(v,w) return v[1] < w[1]; end );</span>
ss"java.lang.StringIndexOutOfBoundsException: Range [64, 60) out of bounds for length 136
 java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 74
[ [ 0, 6 ], [ 0, 4 ], [ 1, 3 ], [ 1, 5 ], [ 1, 2 ], [ 3, 4 ] ]
</pre></div>

<><a ="java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 62

<h5>21.18-2 SortParallel</h5>

divclass"">class""100 =java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 122
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; StableSortParallel</code>( <var class="Arg">list1</var>, <var class="Arg">list2</var>[, <var class="Arg">func</var>] )</java.lang.StringIndexOutOfBoundsException: Range [0, 223) out of bounds for length 121
<> class="<>java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 467

p> =f =;java.lang.StringIndexOutOfBoundsException: Range [39, 37) out of bounds for length 124


d "example"<pre
<"java.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 100
<=GAPprompt">java.lang.StringIndexOutOfBoundsException: Range [27, 27) out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="GAPinput">list1;</span>
[ 1, ,5,divclass="nc< class=unc"=100"tr>td=dleft"<codeclass="8227 <(var "java.lang.StringIndexOutOfBoundsException: Range [151, 150) out of bounds for length 291
<span class="GAPprompt">gap></span> <span class="GAPinput">list2;</span>
[ 7, 3, 2, 9, 5, 8 ]
<pre</>

pthat<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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

<h5>21.18-3 Sortex</h5>

<div class="func"><table class="func" width="100
<>the list< classclass"ap>/span< =list2<pan

<p><code class="func">Permuted</code> (<a href="chap21.html#X7B5A19098406347A"><span class="RefLink">21.20-17</span></a>) allows you to rearrange 


<div class="example"><pre>
<spanjava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 100
<span class="GAPprompt">gap></span> <span class="GAPinput">list2 := span class="GAPprompt">gap></span> <span class="GAPinput">Collected( last );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">perm := Sortex( list1 );</span>
(1,3,5,6,4)
<span class="GAPprompt">gap></span> <p>sorts the list <var class="Arg">list</var> and returns a permutation that can be applied to <var class="Arg">list</var> to obtain the sorted list. The one argument form sorts via the operator <code class="code"><</code>, the two argument form sorts w.r.t. the function <var class="Arg">func</var>.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ 1, 4, 5, 5, 6, 7 ]
<span class="GAPprompt">gap></span> <span 
[ 1, 4, 5, 5, 6, 7 ]
</pre></div>

<< =" ="func<tableclass="func "100"><>td=tdleft">< class="func">&#8227; DuplicateFreeList</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation< =func"<tableclass=java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 217

<h5>21.18-4 SortingPerm</h5>

<div class="func"><java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
<p>codeclass=func">/><p><code class="func">SortingPerm</code> returns


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1
<span class="GAPprompt">gap></span> <span class="GAPinput">list2 := ShallowCopy( list1 );;</span>
spanG"gtspan<" Sjava.lang.StringIndexOutOfBoundsException: Range [83, 81) out of bounds for length 98
(1,3,5,6,4)
<java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
[ 5, 4, 6, 1, 7, 5 ]
<="GAPprompt>gap&</span> < ">Permuted<spanclass="GAPprompt"gap>/ <span =GAPinput">list1 := [ 5, 4, 6, 1, 7, 5 ];;</span>
[ 1, 4, 5,s ><div class="func"><table cl=%tr> ">f"&8227java.lang.StringIndexOutOfBoundsException: Range [122, 120) out of bounds for length 230
</pre><p>java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 198

<>"80java.lang.StringIndexOutOfBoundsException: Range [62, 27) out of bounds for length 62

<h4> 1,4 ,, ,7]

<p>Searching objects in a list works much quicker if the list is known to be sorted. Currently <strong class

<p>Remember that a list of <em>mutable<

<>  lists are used to represent <>sets</em> <trong class=

<p>In short proper sets are represented by sorted lists without holes and duplicates in <strong class="pkg">GAP</strong>. Note that "unc"F/ firstmakesa emptylist v

<p>In some contexts (for example see <a href="chap16.html#X7BDA99EE7CEADA7C"><span class="java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 0

<p> 1,2,3, 1,2 java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 263

<p>There are nondestructive counterparts of the functions <code class="func">UniteSet</code> (<a href="chap21.html#java.lang.StringIndexOutOfBoundsException: Index 121 out of bounds for length 81

<p>The result of <code class="code">IntersectionSet</code> and

<>The result of <ode class="code">IntersectionSet</code> and <code class="code">UnionSet</code> is always a new list, that is not identical to any other java.lang.StringIndexOutOfBoundsException: Index 159 out of bounds for length 117

<h5><code>21h5><ode2119-\n/code> 10][11  , [13 ]

<div class="func"><table class="funcd class"unc>table class="func" width="100%"><tr><td class="tdleft"><p><aid"X7C4FDB007C3F54A1" name"X7C4FDB007C3F54A1"><a><p>
<p>For a list <var class="Arg">list</var> that stores that it is strictly sorted, the test with <code class<h5>.- Reversed</>

p>aid="name"java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 27

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<class"><able =func" width="100%"><tr><td class="">code class="java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<s="Arg">list1</var> is an

<p>If both lists are proper sets then they are of course equal if and java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
<span> <span class=GAPinput"java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 113
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsEqualSet( [2,3,5,7,11], [2,3,5,7,11,13] );</span>
false
</pre></div>

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

<5>21.193/h5

<div class="func>< =func"width"100%>>tdclass=tdleft">code classfunc"&8227; <
<p>tests whether every element of <var class="Arg">list2</var> is contained in <var class="Arg">list1</var>. java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p><a id="X832C23CC7FCD8892" name="X832C23CC7FCD8892">< =

<h5>21.19-4 AddSet<< ="g&;/><java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 98

<div class="func"t class"func width="100,,,,9
<p>adds the element <var class="Arg">obj</var> to the proper set <var class="Arg">set</var>. If <var java.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 71

<p>ote  < <ivclass=xample"<>


ijava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 26
<span class="GAPprompt">gap></span> <span class="GAPinput 2<iv
<span class="java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 0
[ 2, 3,2, 3 5,7,1113 
<span class="GAPprompt">gap></span class=GAPprompt
[ 2, 3, 5, 7, 11, 13 ]
<java.lang.StringIndexOutOfBoundsException: Range [43, 5) out of bounds for length 88
[ 2, 3, 5, 7, 11, 13 ]
/<>

<p><a id="X7FCA282E789A4F4B" name="X7FCA282E789A4F4Bdivclass="func"

<h5>21195 />

<div class="func"><table class="func" width="100%"><tr><td class="tdleft">div class=example/><div>
<p>removes the element <var class="Arg">obj</var> from the proper set <var class="Arg">set</var>. If <var class="Arg"><span="gap;/span <java.lang.StringIndexOutOfBoundsException: Range [46, 5) out of bounds for length 62


<div class="example"><pre>
<java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 96
<span class="GAPprompt">gap></span> <span class="GAPinput">RemoveSet( s, 6 /var to    list<ar ="
[ 2, 3, 4, 5, 7 ]
<span class="GAPprompt">gap></span>
[ , 3,4, <v=example<
</pre></div>

7java.lang.StringIndexOutOfBoundsException: Range [33, 27) out of bounds for length 62

<h5>21.19-6 UniteSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; UniteSet</code>( <var class="Arg">set</var>, <var class="Arg">list</var> )</td><td class="tdright">( java.lang.StringIndexOutOfBoundsException: Index 212 out of bounds for length 26
<p>unites the proper set <var class="Arg">set</var> with <var class="Arg">list</var>. This is equivalent to adding all elements of <var class="java.lang.StringIndexOutOfBoundsException: Index 146 out of bounds for length 104


<div class="example"><pre>
<=>>/> <""UniteSet  16,,,( java.lang.StringIndexOutOfBoundsException: Range [107, 106) out of bounds for length 415
<span class="GAPprompt">gap></span> <span class="GAPinput">UniteSet( set, [ 4, 8, 9 ] );  set;</span>
[ 2, 3, 4, 5, 7, 8, 9, 11 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">UniteSet( set, [ 16, 9, 25, 13,<2, 3,,57 ,9,11 , 6 25java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
[ 2, <pre></div>
</pre></div>

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

<h5>21.19-7 IntersectSet</h5>

<div class="func"><table class="func" width=
<p>intersects the proper set <var class="Arg">set</var> with <var class/>/java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12


<div class="example"><pre>
<span class<>.-12spanclass=H">span>/h5java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
<span class="GAPprompt">gap></span> <span class="GAPinput">IntersectSet( set, [ 3, 5, 7, 9,java.lang.StringIndexOutOfBoundsException: Range [12, 10) out of bounds for length 274

<spanclass="GAPprompt>gt/span<"java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 127
  ]
</pre></div>

<>java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<h5>1.-8 java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 28

<div class="func"><java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 3
<r>. Thisjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3


< ="pre>
<span class="GAPprompt">gap></span> <span class="java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 12
<span class="GAPprompt">gap></span> <span class="GAPinput">SubtractSet< theindexof maximumclassjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 26
[ 2, 3, 4, 5, 7, 8, 9, 11 ]
<java.lang.StringIndexOutOfBoundsException: Range [44, 5) out of bounds for length 110
[ 2, 3, 5, 7, 11 ]
</pre></div>

<>a ="java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 62

42120<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Several of the following functions expect the

<p><a id=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h5>21.""t "func >java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 263

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">pInthe first  < Xjava.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 62
<div class="func"><table class<h521.0- /h5>
<p>In the first form <code class="func">Concatenation</code> returns the concatenation of class="<java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 282

<p>In the second form <ivclass=func"<table class= width"%><d ">f">&#8227; Concatenation</code>( <var class="Arg">list</var> )</d< java.lang.StringIndexOutOfBoundsException: Range [167, 166) out of bounds for length 223

<p>The result is a new mutable list, java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<p>Note that <code class="func">Concatenation</code> creates a new list and leaves its arguments unchanged, while <code class="func">AppendNotethat  both<class=>java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 426


<div class="example"><pre>
<span class<span class"APprompt"g&<span> < class=APinput>Minimum 123 ,123, 0,1000 ;/>
[ 1, 2, 3, 4, 5 ]
<span class="GAPprompt">java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 5
[
<
[ 1, 2, 3, 2, 3, 4, 3, 4, 5 ]
</pre>/java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

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

<2120 java.lang.StringIndexOutOfBoundsException: Range [23, 21) out of bounds for length 26

<div class="GAPprompt">gap></span> <span class="GAPinputjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
p  newmutable  that  java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 133


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">p> a argument <arclass=Arg">/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ 1, 3, 4, [ 5,,, 6 ], 7 ]
</pre></div>

<" nameX"><</>

<h5>21.20-3 Collected</h5>

< class""<=example"<>
<p>returns a new list <var class="Arg">new</var> that contains for each element <var class="Arg">elm</var> of the list <var class="Arg">list</var> a

<p>For all pairs of elements in <var class="Arg">list</var> the comparison via <code class="code">&an style='color: green'>1,3 ,  5,6 


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Factors( Factorial( 10 ) );</span>
[ 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 7 ]
<
[ 2 ] 34 ,[5, ] [,1 ]
<span=GAPprompt>java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 87
[ [ [ 2, 8 ], 1 ], [ [ 3, 4 ], 1 ], [ [ 5, 2 ], 1 ], [ [ 7, 1 ], 1 ] ]
</pre></div>

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

<h5>21. [2, 3 6 ] [2, 4, 5 ], [ 2, 4, 6 ] ]

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code java.lang.StringIndexOutOfBoundsException: Range [0, 85) out of bounds for length 0
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Unique</code>( <var class="Arg">list</var> )</td><td class="tdright">(<class=GAPprompt"gap&;</><class=GAPinput>(Factorial( 10);/pan>
<p>returns a new mutable list whose entries are the elements of the list <var class="Arg">list</var> with duplicates removed. <code class="func">DuplicateFreeList</code> only uses the <code class="code">=</code> comparison and<2 ,2 2 ,,2 2 ,3 3 3 ,5,  

<p><code class="func">Unique</code> is a synonym for [[2, 8, ,4]  ,   7   ]


divclass=example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:=[1,Z(3),1,"abc",Group((1,2,3),(1,2)),Z(3),Group((1,2),(2,3))];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DuplicateFreeList( l );</span>
[ 1, Z(3), "abc", Group([ (1,2,3), (1,2) ]) ]
</pre></div>

<p><a id="X7F5D4DD87E4378AC>.04 <h5>

<h5>21.20-5 AsDuplicateFreeList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; AsDuplicateFreeList</code>( <var class="Arg">list</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the same result as <code class="func">DuplicateFreeList</code> (<a href="chap21.html#X8727F2928467C2F9"><span class="RefLink">21.20-4</span></a>), except that the result is immutable.</p>

<><aid="X7FA272D984EF82ED"name="X7FA272D984EF82ED"></a></p>

<h5>21.20-6 Flat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Flat</code>( <var class="Arg">list</var> )</td><td class="tdright">( 
<p>returns the list of all elements that are contained in the list <var class="Arg">list</var> or its sublists. That is, <code class="func">Flat</code> first makes a new empty list <var class="Arg">new</var>. Then it loops over the elements <var class="Arg">elm</var> of <var class="Arg">list</var>. If <var class="Arg">elm</var> is not a list it is added to <var class="Arg">new</var>, otherwise <code class="func">Flat</code> appends span class="APprompt"gap></><panclass="GAPinput">DuplicateFreeList( l );</span>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Flat( [ 1
[ 1, 2, 3, 1, 2, 3 ]

[  ]
</pre>/iv>

<p>To reconstruct a matrix from the list obtained by applying <code class="func">Flat</code> to the matrix, the sublist operator can be java.lang.StringIndexOutOfBoundsException: Range [0, 140) out of bounds for length 32


<div class="example"><pre>
<span 
<span class="GAPprompt">gap></span> <span class="GAPinput">sub:=[1..w];;List([1..Length(l)/w],i->l{(i-1)*w+sub});</span>
[ [ 9, 10 ], [ 11, 12 ],
</pre></div>

<p><a id="X7C4FDB007C3F54A1" name="div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AsDuplicateFreeList</code>( <var class="Arg">list</var> )</td><td class="tdright">( attribute )</td></tr></table></div>

<h5>21.20-7 Reversed</h5>

<div"><code <p<a="name=""</><>
<p>java.lang.StringIndexOutOfBoundsException: Range [3, 10) out of bounds for length 0

<p>The argument list is unchanged. The result list is a new list, that is not identical to any other list. The elements of<p>In the  form <ode class="func><div class="func"><table class="func" width="100%tr><td class="tdleft"><code class="func">&#8227; Flat</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>

<p> =unc"Reversed/code>  case oflist java.lang.StringIndexOutOfBoundsException: Range [83, 82) out of bounds for length 255

<p>span class">gap&t<  "APinput"  1  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap&
 7 ,5 ,1]
</pre></div>

<java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0

<h5>21.20-8 Shuffle</h5>

<div class="func[[ 9 10]  11 12]  13 14]]
<p>The argument <var class="Arg">list</var> must be a dense mutable list. This operation permutes the entries of <var class="Arg">java.lang.StringIndexOutOfBoundsException: Index 133 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Reset(GlobalMersenneTwister, 12345);; # make manual tester happy</span>
< java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 82
[ 1 .. 20 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">m := Shuffle(ShallowCopy(l));</span>
[ 8, 13, 1, 3, 20i argumentlist   The list  anewlist isidentical to any other list. The elements of that list however are identical to the corresponding elements of the argument list (see <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a>).</p>
  14 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l;</span>
[ 1 .. 20 ]
<pan"java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 81
<span class="GAPprompt">gap></span> <span class="GAPinput
[ 19, 5, 7, 20, 16, 1, 10, 15, 12, 11, 13, 2, 14, 3, 4, 17, 6, 8, 9,
  18 ]
</pre></div>

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

<5>.-9 Apply<h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Apply</code>( <var class="Arg"<>a =" name=X8057372F83374193>/>/>
<p><code class="func">Apply</code> applies the function <var class="Arg">func</var> to every element of the dense and mutable list <var class="Arg">list</var>, and replaces each element entry by the corresponding return value.</p>

<p><code class="func">Apply</code> changes its argument. The nondestructive counterpart of <code class="func">Apply</code> is <code class="func">List</code> (<a href="chap30.html#X7F12F40E87F3C3A7"><span class="RefLink">30.3-5</span></a>).</p>


<div class="example"><pre>
<java.lang.StringIndexOutOfBoundsException: Range [50, 5) out of bounds for length 116
[ 1, 4, 9 ]
</pre></div>

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

<h5>21.20-10 Perform</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; span ="APprompt>gap&;/span span "l =[.20;/pan>
<p><code class="func">Perform</code> applies the function <var class="Arg">func</var> to every element java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 98


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l  >&t;/span>< ";java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 71
<span class="GAPprompt< java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 81
2
3
</pre></div>

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

<5>.- PermListList</>

<divjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>returns a permutation <span class="SimpleMath">p</span> of <code class="code">[ 1 .. Length( <var class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<class"<pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ 5, 4, 6, 1, 7, 5 ];;</span>
java.lang.StringIndexOutOfBoundsException: Index 209 out of bounds for length 100
<span class="GAPprompt">gap></span> <span class="GAPinput">perm := PermListList(list1, list2);java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(1,2,4)(3,5,6)
<span class="GAPprompt">gap></span> <span class="GAPinput">Permuted( list2, perm );</span>
[ 5, 4, 6, 1, 7, 5 ]
</pre></p>a id" name="7>/>/>

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

<h5>21.20-12 <span class="Heading">Maximum<

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Maximum</code>( <var <p><code class="func">Perform</code> applies the function <var class="Arg">func</var> to every element of the list <var class="Arg any return values.   not  avalue./java.lang.StringIndexOutOfBoundsException: Index 205 out of bounds for length 205
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Maximum</code>( <var class="Arg">list</var> )</td><td class="tdright">( d class">java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<p>In the first form <code class="func">Maximum</code> returns the <em>maximum</em> of its arguments, i.e., one argument <var class="Arg">obj</var> for which <span class="SimpleMath"><var class="Arg">obj< java.lang.StringIndexOutOfBoundsException: Range [86, 84) out of bounds for length 124

<p>In the second form <code class="func">Maximum</code> takes a homogeneous list <var class="Arg">list</var> and returns the maximum of the elements in this java.lang.StringIndexOutOfBoundsException: Range [0, 161) out of bounds for length 12


<div class="example"><pre>
<span
700
<span class="GAPprompt">gap></span> <span class="GAPinput">Maximum( [ -123, 700, 123, 0, -1000 ] );</span>
700
<span class="GAPprompt">gap></span> <span class="GAPinput"># lists are compared elementwise:</span>
<span class
[ 2, -11 ]
</pre></div>

<p>To get the index of the maximum element use <code class="func">PositionMaximum</code> (<a href="chap21.html#X7FD9C1D37F300206"><span class="<p>To get the index of the maximum element use <code class="func">PositionMaximum</code> (<a href="chap21.html#X7FD9C1D37F300206"><span class="RefLink

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

<5212013span "java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 54

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Minimum</code>( <var class="Arg">obj1</var>, <var class="Arg">obj2</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">&#an style='color: green'>8227; Minimum<<5>.2012<span class"Heading">aximum</span<h5>
<p>In the first form <code class="func">Minimum</code> returns the <em>minimum</em> of its arguments, i.e., one argument <var class="Arg">obj</var> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>In the second form <code class="func">Minimum</code> takes a homogeneous list <var  class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func( varclass=list</>)/td>="&&)</>t>></div>

<p>Note that for both <code class="func">Maximum</code> (<a href="chap21.html#X82CE0DE8828E4303"><span class="RefLink">21.20-12</span></a>) and <code class="func">Minimum</code> the comparison of the java.lang.StringIndexOutOfBoundsException: Index 202 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Minimum( -123, 700, 123, 0, -1000 );</span>
-1000
<span class="GAPprompt">gap></span> <span class="GAPinput">Minimum( [ -123, 700, 123, 0, -1000 ] );</span>
-1000
<span class="GAPprompt">gap></span> <span class="GAPinput">Minimum( [ 1, 2 ], [ 0, 15 ], [ 1, 5 ], [ 2, -11 ] );</span>
[ 0, 15 ]
<pre></div>

<p>To get the index of the minimum element use <code class="func">PositionMinimum</code> (<a href="chap21.html#X7FD9C1D37F300206"><span class="RefLink">21.16-8</span></a>)</p>

<p><a id[2 11]

<h5>21.20-14 <span class="Heading">MaximumList and MinimumList</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; MaximumList</code>( <var class="Arg">list</var<<a"java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62
<div class="func"><table class="func" width="100%"><tr><521.20
<p>return the maximum java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 0

<p>If a second argument <var class="Arg">seed<<div ="unc"<tableclass=func"width="100"<>td class=tdleft">cclass="unc>#;Minimum</code( varclass"Arg">list/var>)/>tdclass="dright"(nbsp;unction&bsp;)<>/r<table><div

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

<h5>21.20-15 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Cartesian</code>( <var class="Arg">list1</var>, <var class="Arg">list2</var>, <var class="Arg">...</var> )</td><td class="java.lang.StringIndexOutOfBoundsException: Range [0, 230) out of bounds for length 0
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Cartesian</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In the first form <code class="func">Cartesian</code> returns the cartesian product of the lists <var class="Arg">list1</var>, <var class

<p>In the second form <var class="Arg">list</var> must be a list of lists <var class="Arg">list1</var>, <var class="Arg">list2</var>, etc., and <code class="func">Cartesian</code> returns the cartesian product of those lists.</p>

<p>The <em>cartesian product</em> is a list <var class="Arg">cart</var> of lists <var class="Arg">tup</var>, such that java.lang.StringIndexOutOfBoundsException: Index 122 out of bounds for length 9

<p>The last index runs fastest. That means that the first element <var class="Arg">tup1</var

<p>The function <code class="func">h>.-14<spanclass="Heading">MaximumList and MinimumList</span></h5>


<""<pre>
<pan=GAPprompt"gap&<span><class=GAPinput"Cartesian [2] , 56] ;/>
[ [ 1, 3, 5 ],returnthe maximum resp. the minimum of the elements in the list <var class="Arg">list</var>. They are the operations called by <code class="func">Maximum</code> (<a href="chap21.html#X82CE0DE8828E4303"><span class="RefLink">21.20
  [ 2, 3, 6 ], [ 2, 4, 5 ], [ 2, 4, 6 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Cartesian( [1,2,2], [1,1,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ [ 1, 1 ], [ 1,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  [ 2, 1 ], [ 2, 1 ], [ 2, 2 ] ]
</pre><< =func">table""width=100%><<java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 278

<><a="E76java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 62

<h5>21.20-16 <span class="Heading">IteratorOfCartesianProduct</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IteratorOfCartesianProduct<
<div class="func"><table class="func" width="100%"><tr><td class=">/>div>
<> first < class="unc">teratorOfCartesianProduct</ode> returns an iterator (see ahref=chap30.tml"< java.lang.StringIndexOutOfBoundsException: Range [151, 150) out of bounds for length 426

<p>In the second form <var class="Arg">list</var> must be a list of lists <var class="Arg">list1</var>, <var class="Arg">list2</var>, etc., and <code class="func">IteratorOfCartesianProduct</code> returns an iterator of the cartesian product of those lists.</p>

<p>Resulting tuples will be returned in the lexicographic order. Usage of iterators of cartesian products is recommended in the case when the resulting cartesian product is big enough, so its generating and storage will require essential amount of runtime and memory. For smaller cartesian products it java.lang.StringIndexOutOfBoundsException: Index 304 out of bounds for length 0

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

<h5>21.20-17 Permuted</h5>

djava.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 248
<p>returns a new list <var class="Arg">new</var> that contains the elements of the list <var class="Arg">list</var> permuted according to the permutation <var class="Arg">perm</var>. That is <code class="code"><var class="Arg">new</var>[<var class[ 1 ,5 ,[,,6  [ ,,5]   4, ] [ ,, ]java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

<pan ">>/><pan "java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 99


<div class="example"><pre>
<span class="GAPprompt"/re>div>
[ 1, 4, 5, 5, 6, 7 ]
<span p><a id=X7E76F5A782184823 =">/<pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
[ , 4, 5, 5, 6, 7 ]
</pre></div>

<p<a "86CB7DCE8510F977 name="">/>/>

h>20-8java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 22

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; List</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p entry <code class="code">new[i]</code> is classcode>"rg>/var>]/ode>  c classcode"newi] =varclass=Arg"func<var><ar ">/var>[]<. argument<var =>func<ar is java.lang.StringIndexOutOfBoundsException: Range [445, 443) out of bounds for length 821

<p>Developers who wish to adapt this for custom list or collection types need to install suitable methods for the operation <code class="code">ListOp</code>.</p>


<div class="example"><pre>
<spanIn the second form <var class=Arg">ist/var>must  a list of lists <var class="Arg">list1</var>, <var class="Arg">list2</var>, etc., and <code class="func">IteratorOfCartesianProduct</code> returns an iterator of the cartesian product of those lists.</p>
[ 1, 4, 9 ]
<java.lang.StringIndexOutOfBoundsException: Range [32, 5) out of bounds for length 94
[ false, true, true, false, true, false, true, false, false, false ]
<span class="GAPprompt">gap></span> <span class="GAPinput">List([,1,,3,4], x-> x > 2);</span>
[ , false,, true, true ]
</pre></div>

<p>(See also <code class="func">List</code> (<a href="chap30.html#X7F12F40E87F3C3A7"><span class="RefLink">30.3-5</span></a>).)</p<5>21-17  Permuted</h5>

<

<5>21.20-19 Filtered</h5>

<div class="func"><table class="func" width="100%"><tr><java.lang.StringIndexOutOfBoundsException: Range [0, 58) out of bounds for length 0
<>eturns  java.lang.StringIndexOutOfBoundsException: Range [177, 16) out of bounds for length 308

<p>If the first argument is a list, the order of the elements in the result is the same as the order of the corresponding elements of this list. If an element for which <var class="Arg">func</var> returns <code class="

pFor   of< ""listorcoll<var var =">func<var mustreturneither <code class="keyw">true</code> or <code class="keyw">false</code>, otherwise an error is signalled.</p>

<>Theresult is  new new list that  not identical to any other list. The elements of that list however are identical to the corresponding elements of the argument list (see <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a>).</p>

<p>List assignment using the operator <code class="func" ,4 5 5,, 7 java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

<p>Developers who wish to adapt this for custom list or collection types need to install suitable methods for the operation<p<a id="X86CB7DCE8510F977" name="X86CB7DCE8510F977"></a></p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class=class=">java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 245
[ 2, 3, 5, 7, 11, 13, 17, 19 pThisjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 821
<class=GAPprompt"gap&;span< class""Filtered [,3,4 -, 4,7,10,,  ], )<span
[ 3, 4, 4, 7 ]
<span class="GAPprompt">gap></span> <<p>Developers who wish to adapt this for cus  java.lang.StringIndexOutOfBoundsException: Range [89, 88) out of bounds for length 161
<span class="GAPprompt">></span> <span class="GAPinput">             n -> IsPrimePowerInt(n) and n mod 2 <> <iv =">pre>
[ 3<java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 98
<span class="GAPprompt">gap></span> <span classjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
[ (2,3), (1,2), (1,3) ]
</pre></div>

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

<h5>21.20-20 Number</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Number<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>Called with a list <var class="Arg">listorcoll</var>, <code class="func">Number</code> returns the number of bound entries in this list. For dense lists <code class="func">Number</code>, <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink

<p>Called with two arguments, a list or collection <var class="Arg">listorcoll</var> and a unary function <var class="Arg">func</var>, <code class="func">Number</code> returns the number of returns a new list that contains those elements of the list or collection <var class="Arg">listorcoll</var> (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>), respectively, for which the unary function <var class="Arg">func</var> returns <code class="keyw">true</code>.</p>

<p>For each element of <var class="Arg">listorcoll</var>, <var class="Arg">func</var> must return <p>For each element of <var class="Arg">listorcoll</var>, <var class="Arg">func</var> must return either"true<code>or <code class"><code> otherwise error is signalled<pjava.lang.StringIndexOutOfBoundsException: Index 208 out of bounds for length 208

<p><code class="func">Filtered</code> (<a href="chap21.html#X7C86D7F7795125F0"><span class="RefLink">21.20-19</span></a>) allows you to extract the elements of pListjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 324

<p>Developers who wish to adapt this for custom list or collection types need to install suitable methods for the java.lang.StringIndexOutOfBoundsException: Index 120 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt"gapgt;/span><pan class="GAPinput">Number( [ 2, 3, 5, 7 ] );</span>
4
<span "">&t;/span> <span class="GAPinput>umber [,2,3,, 5,7,,, 11 ] ;</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( [1..20], IsPrime );</span>
8
<panclass="GAPprompt">gap></span> <span class="GAPinput">Number( [ 1, 3, 4, -4, 4, 7, 10, 6 ], IsPrimePowerInt );</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( [ 1, 3, 4, -4, 4, 7, 10, 6 ],</span>
<span class="GAPprompt">></span> <span class="GAPinput">           n -> IsPrimePowerInt(n) and n mod 2  (3) (1,) (,)
2
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( Group( (1,2), (1,2,3) ), x -> Order( x ) = 2 );</span>
3
</pre></div>

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

<h5>21.20-21 First</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; First</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">First</code> returns the first element of the list <var class="Arg">list</var> for which the unary function <var class="Arg">func</var> returns <code class="keyw">true</code>; if <var class="Arg">func</var> is not given, the first element is returned. <var class="Arg">list</var> may contain holes. <var class="Arg">func</var> must return either <code class="keyw">true</code> or <code class="keyw">false</code> for each element of <var class="Arg">list</var>, otherwise an error is signalled. If <var class="Arg">func</var> returns <code class="keyw">false</code> for all elements of <var class="Arg">list</var> then <code class="func">First</code> returns <code class="keyw">fail</code>.</p>

<p><code class="func">PositionProperty</code> (<a href="chap21.html#X7E6C763A82C6153B"><span class="RefLink">21.16-9</span></a>) allows you to find the position of the first element in a list that satisfies a certain property.</p>

<p>Before <strong class="pkg">GAP</strong> 4.12, developers who wished to adapt this for custom list types needed to <ivclass="unc">tableclass=func width""><< "tdleft"< =func"#8227; ermuted/code> <arclass=Arg"list<var>,< ="p<var )td>tdclass=">td>/>table<>


<div class="example"><pre>
<p>a list <arclass="Arg"new/>    elements java.lang.StringIndexOutOfBoundsException: Range [83, 82) out of bounds for length 456
10000019
<span class="GAPprompt">gap></span> <span class="GAPinput">First( [10^5..10^6],</span>
<span class="GAPprompt">></span> <span class="GAPinput">     n -> not IsPrime(n) and IsPrimePowerInt(n) );</span>
100489
<span class="GAPprompt">gap></span> <span class="GAPinput">First( [ 1 .. 20 ], x -> x < 0 <>code =func">/code < "java.lang.StringIndexOutOfBoundsException: Range [188, 52) out of bounds for length 222
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">First( [ fail ], x -> x = fail );</span>
fail
</pre></div>

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

<h5>21.20-22 Last</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Last</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">Last</code> returns the last element of the list <var class="Arg">list</var> for which the unary function <var class="Arg">func</var> returns <code class="keyw">true</code>; if <var class="Arg">func</var> is not given, the last element java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<>java.lang.StringIndexOutOfBoundsException: Range [17, 13) out of bounds for length 147


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Last( [10^7..10^8], IsPrime );</span>
99999989
<span class="GAPprompt">gap></span> <span class="GAPinput">Last( [10^5..10^6],</span>
<span class="GAPprompt">></span> <span class="GAPinput">     n -> not IsPrime(n) and IsPrimePowerInt(n) );</span>
994009
<span class="GAPprompt">gap></span> <span class="GAPinput">Last( [ 1 .. 20 ], x -> x < 0 );</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">Last( [ fail ], x -> x = fail );</span>
fail
</pre></div>

<p><a id"X7F06961278166671" ="F06961278166671"></a></p>

<h5>21.20-23 ForAll</h5>

<div class=func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#n style='color: green'>8227; ForAll</code>( <var class="Arg">listorcoll</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>tests whether the unary function <var class="Arg">func</var> returns <code class="keyw">true</code> for all elements in the list or collection <var class="Arg">listorcoll</var>.</p>

<p>Developers who wish to adapt this for custom list or collection =">gap&;<span>span ="GAPinput">List( [1,2,3], i -> i^2 );/span>


<div class="example false , false, true,  ,false java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll( [1..java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
false
<span class=GAPprompt"gap&;/span><class">( 2,45,8] IsPrimePowerInt )<span>
true
<span class="GAPprompt">gap></java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 26

<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll( Group( (1,2), (1,<p>eturns a new thatthosejava.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 308
false
</pre></div>

<><aid"X7AF82E747A8BDA75" name=X7F82E747A8BDA75"></a></p>

<21.2024 java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 24

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ForAny</code>( <var class="Arg">listorcoll</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></trjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>  java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 192

<p>Developers who wish to <p>Developers who wish to adapt  java.lang.StringIndexOutOfBoundsException: Range [72, 66) out of bounds for length 165


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAny( [1..20], IsPrime );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAny( [2,3,4,5,8,9], IsPrimePowerInt );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAny( [2..14],</span>
<=GAPprompt"&<span><spanclass"GAPinput"   n -gt;IsPrimePowerInt()and n  55  0 not ())<span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAny( Integers, i ->     i > class">umberOp</code/
<span class="GAPprompt">></span> <span class="GAPinput">                          and ForAll( [0,2..4], j -> IsPrime(i+j) ) );</span>
true
</pre></div>

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

<h5>21.20-25 Product</h5>

<div class="func"><table class="func" width="100%"><trjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>Called with one argument, a dense list or collection <var class="Arg">listorcoll</var>, <code class="func">Product</code> returns the product of the elements 

<p>Called with a dense list or collection <var class="Arg">listorcoll</var> and a function <var class="Arg">func</var>, which must be a functionspan class="GAPprompt">gap></span> <span class="GAPinput">Number( [, 2, 3,, 5,, 7,,,, 11 ] );</span>

<p>The general rules for arithmetic operations div class="func"><table class="func" width="100%"> class"tdleft><code class="func">&#8227; First</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( operation )</td></tr></table></div>

<p>If <var class="Arg">listorcoll</var> contains exactly one element then this element (or its image under <var class="Arg">func</var> if applicable) itself is returned, not a shallow copy of this element.</p>

<p>If an additional initial value <var class="Arg">init</var> is given, <code class="func">Product</code> returns the product of <var class="Arg">init</var> and the elements of the first argument resp. of their images under the function <var class="Arg">func</var>. This is useful for example if the first argument is empty and a different identity than <code class="code">1</code> is desired, in which case <var class="Arg">init</var> is returned.</p>

<p>Developers who wish to adapt this for custom list or collection types need to install suitable methods for the operation <code class="code">ProductOp</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Product( [ 2, 3, 5, 7, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
9699690
<span class="GAPprompt">gap></span> <span class="GAPinput">Product( [1..10], x->x^2 );</span>
13168189440000
<span class=</re></ivjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
(1,4)(2,3)
sclass"GAPprompt>;s>s class=GAPinput>(GF(8) )</>
0**(2)
/>divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<></java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>21.20-26 Sum</h5>

<java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
<p>Called with one argument, a dense <p><class="func">First</code> returns the first element of the list <var class="Arg" thisfor  java.lang.StringIndexOutOfBoundsException: Range [83, 52) out of bounds for length 147

<

<p>The general rules for arithmetic operations apply (see <a href="chap21.html#X8676EFE67972FD06"><span class="RefLink">21.span ">gap;/pan <class=GAPinput"Last(107.^], IsPrime )span

<p>If <var class="Arg">listorcoll</var> contains exactly one element then this element (or its image under <var class="Arg">func</var> if applicable) itself is returned, not a shallow copy of this element.</p>

<> an additional initial value <var class="Arg">init</ut>Last [ 1. 20 ],x -> x < 0 );</span>

<p>Developers who wish to adapt this for custom list or collection types need to install suitable methods for the operation <code class="code">SumOp</code>.</p>


<div <span class";>sclass=>    -; n java.lang.StringIndexOutOfBoundsException: Range [91, 90) out of bounds for length 119
<span class="GAPprompt"span =""gap&;<span><panclass=GAPinput>([1 . 20],x -gt;x&t;  ;/span>
77
<pan =>gt;<span spanail
385
<span class="GAPprompt">gap></span> <span class="GAPinput">Sum( [ [1,2], [3,4], [5,6] ] );</span>
[<<
<spanclass="GAPprompt>gapgt<span>span<p><a id="X7E5B62E780421CE9" name="X7E5B62E780421C/>/>
0*Z(2)
</pre></div>

<< id=" name"834E4DF57F3A20F0<a>/pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>21.20-27 Iterated</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Iterated</code>( <var class="Arg">list</var>, <var class="Arg">f</var> )</java.lang.StringIndexOutOfBoundsException: Range [0, 177) out of bounds for length 0
pjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 617


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Iterated( [ 126, 66, 105 ], Gcd );</span>
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
</pre></div>

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

<h5>21.20-28 ListN</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ListN</code>( <var classfail
<p>applies the <span class="SimpleMath">n</span>-argument function <var class="Arg


<div class="example"><pre>
<span class="GAPprompt">gap&<5>21.20-3ForAll<</h5>
[ 4, 6 ]
</pre></div>

<p><a id="X805CA0B68029B47A>whetherthe unary  v =Arg"/  code class""><>for    the  or  var ="listorcollv></>

java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 71

<p>The following functions are generalizations of <code class="func">List</code> (<a href="chap30.html#X7F12F40E87F3C3A7"><span class="RefLink">30.3-5</span></a>), <code class="func">Set</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>), <code class="func">Sum</code> (<a href="chap21.html#X7A04B71C84CFCC2D"><span class="RefLink">21.20-26</span></a>), and <code class="func">Product</code> (<a href="chap21.html#X7E5C72F27B657948"><span class="RefLink">21.20-25</span></a>).</p>

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

<h5>21.21-1 ListX</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ListX</code>( <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <var class="Arg">...</var>, <var class="Arg">argn</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">ListX</code> returns a new list constructed from the arguments.</p>

<p>Each of the arguments <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <span class="SimpleMath">...</span> <var class="Arg">argn</var> must be one of the following:</p>


<dl>
<dt><strong class="Mark">a list or collection</strong></dt>
<dd><p>this introduces a new for-loop in the sequence of nested for-loops and if-statements;</p>

</dd>
<dt><strong class="Mark">a function returning a list or collection</strong></dt>
<dd><p>this introduces a new for-loop in the sequence of nested for-loops and if-statements, where the loop-range depends on the values of the outer loop-variables; or</p>

</dd>
<dt><strong class="Mark">a function returning <code class="keyw">true</code> or <code class="keyw">false</code></strong></dt>
<dd><p>this introduces a new if-statement in the sequence of nested for-loops and if-statements.</p>

</dd>
</dl>
<p>The last argument <var class="Arg">func</var> must be a function, it is applied to the values of the loop-variables and the results are collected.</p>

<p>Thus <code class="code">ListX( <var class="Arg">list</var>, <var class="Arg">func</var> )</code> is the same as <code class="code">List( <var class="Arg">list</var>, <var class="Arg">func</var> )</code>, and <code class="code">ListX( <var class="Arg">list</var>, <var class="Arg">func</var>, x -> x )</code> is the same as <code class="code">Filtered( <var class="Arg">list</var>, <var class="Arg">func</var> )</code>.</p>

<p>As a more elaborate example, assume <var class="Arg">arg1</var> is a list or collection, <var class="Arg">arg2</var> is a function returning <code class="keyw">true</code> or <code class="keyw">false</code>, <var class="Arg">arg3</var> is a function returning a list or collection, and <var class="Arg">arg4</var> is another function returning <code class="keyw">true</code> or <code class="keyw">false</code>, then</p>

<p><code class="code"><var class="Arg">result</var> := ListX( <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <var class="Arg">arg3</var>, <var class="Arg">arg4</var>, <var class="Arg">func</var> );</code></p>

<p>is equivalent to</p>


<div class="example"><pre>
result := [];
for v1 in arg1 do
  if arg2( v1 ) then
    for v2 in arg3( v1 ) do
      if arg4( v1, v2 ) then
        Add( result, func( v1, v2 ) );
      fi;
    od;
  fi;
od;
</pre></div>

<p>The following example shows how <code class="func">ListX</code> can be used to compute all pairs and all strictly sorted pairs of elements in a list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ 1, 2, 3, 4 ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">pair:= function( x, y ) return [ x, y ]; end;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListX( l, l, pair );</span>
[ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 2, 1 ], [ 2, 2 ],
  [ 2, 3 ], [ 2, 4 ], [ 3, 1 ], [ 3, 2 ], [ 3, 3 ], [ 3, 4 ],
  [ 4, 1 ], [ 4, 2 ], [ 4, 3 ], [ 4, 4 ] ]
</pre></div>

<p>In the following example, <code class="func">\<</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) is the comparison operation:</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListX( l, l, \<, pair );</span>
[ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ], [ 3, 4 ] ]
</pre></div>

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

<h5>21.21-2 SetX</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; SetX</code>( <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <var class="Arg">...</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The only difference between <code class="func">SetX</code> and <code class="func">ListX</code> (<a href="chap21.html#X8258477D7F72171B"><span class="RefLink">21.21-1</span></a>) is that the result list of <code class="func">SetX</code> is strictly sorted.</p>

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

<h5>21.21-3 SumX</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; SumX</code>( <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <var class="Arg">...</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">SumX</code> returns the sum of the elements in the list obtained by <code class="func">ListX</code> (<a href="chap21.html#X8258477D7F72171B"><span class="RefLink">21.21-1</span></a>) when this is called with the same arguments.</p>

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

<h5>21.21-4 ProductX</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ProductX</code>( <var class="Arg">arg1</var>, <var class="Arg">arg2</var>, <var class="Arg">...</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">ProductX</code> returns the product of the elements in the list obtained by <code class="func">ListX</code> (<a href="chap21.html#X8258477D7F72171B"><span class="RefLink">21.21-1</span></a>) when this is called with the same arguments.</p>

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

<h4>21.22 <span class="Heading">Ranges</span></h4>

<p>A <em>range</em> is a dense list of integers in arithmetic progression (or degression). This is a list of integers such that the difference between consecutive elements is a nonzero constant. Ranges can be abbreviated with the syntactic construct</p>

<p><code class="code">[ <var class="Arg">first</var>, <var class="Arg">second</var> .. <var class="Arg">last</var> ]</code></p>

<p>or, if the difference between consecutive elements is 1, as</p>

<p><code class="code">[ <var class="Arg">first</var> .. <var class="Arg">last</var> ]</code>.</p>

<p>If <code class="code"><var class="Arg">first</var> > <var class="Arg">last</var></code>, <code class="code">[ <var class="Arg">first</var> .. <var class="Arg">last</var> ]</code> is the empty list, which by definition is also a range; also, if <code class="code"><var class="Arg">second</var> > <var class="Arg">first</var> > <var class="Arg">last</var></code> or <code class="code"><var class="Arg">second</var> < <var class="Arg">first</var> < <var class="Arg">last</var></code>, then <code class="code">[ <var class="Arg">first</var>, <var class="Arg">second</var> .. <var class="Arg">last</var> ]</code> is the empty list. If <code class="code"><var class="Arg">first</var> = <var class="Arg">last</var></code>, <code class="code">[ <var class="Arg">first</var>, <var class="Arg">second</var> .. <var class="Arg">last</var> ]</code> is a singleton list, which is a range, too. Note that <code class="code"><var class="Arg">last</var> - <var class="Arg">first</var></code> must be divisible by the increment <code class="code"><var class="Arg">second</var> - <var class="Arg">first</var></code>, otherwise an error is signalled.</p>

<p>Currently, the integers <var class="Arg">first</var>, <var class="Arg">second</var> and <var class="Arg">last</var> and the length of a range must be <em>small integers</em> as defined in chapter <a href="chap14.html#X853DF11B80068ED5"><span class="RefLink">14</span></a>.</p>

<p>Note also that a range is just a special case of a list. Thus you can access elements in a range (see <a href="chap21.html#X7921047F83F5FA28"><span class="RefLink">21.3</span></a>), test for membership etc. You can even assign to such a range if it is mutable (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>). Of course, unless you assign <code class="code"><var class="Arg">last</var> + <var class="Arg">second</var> - <var class="Arg">first</var></code> to the entry <code class="code"><var class="Arg">range</var>[ Length( <var class="Arg">range</var> ) + 1 ]</code>, the resulting list will no longer be a range. Note that assigning to an entry of <var class="Arg">range</var> will convert it back into a plain list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">r := [10..20];</span>
[ 10 .. 20 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Length( r );</span>
11
<span class="GAPprompt">gap></span> <span class="GAPinput">r[3];</span>
12
<span class="GAPprompt">gap></span> <span class="GAPinput">17 in r;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput"># r still is a range but is now represented as a plain list</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">r[1] := 10;; r;</span>
[ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange(r);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput"># r is no longer a range</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">r[12] := 25;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange(r);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">r := [1,3..17];</span>
[ 1, 3 .. 17 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Length( r );</span>
9
<span class="GAPprompt">gap></span> <span class="GAPinput">r[4];</span>
7
<span class="GAPprompt">gap></span> <span class="GAPinput">r := [0,-1..-9];</span>
[ 0, -1 .. -9 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">r[5];</span>
-4
<span class="GAPprompt">gap></span> <span class="GAPinput">r := [ 1, 4 .. 32 ];</span>
Error, Range: <last>-<first> (31) must be divisible by <inc> (3)
</pre></div>

<p>Most often ranges are used in connection with the <code class="keyw">for</code>-loop see <a href="chap4.html#X78783E777867638A"><span class="RefLink">4.15-6</span></a>). Here the construct</p>

<p><code class="code">for <var class="Arg">var</var> in [ <var class="Arg">first</var> .. <var class="Arg">last</var> ] do <var class="Arg">statements</var> od</code></p>

<p>replaces the</p>

<p><code class="code">for <var class="Arg">var</var> from <var class="Arg">first</var> to <var class="Arg">last</var> do <var class="Arg">statements</var> od</code></p>

<p>which is more usual in other programming languages.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">s := [];; for i in [10..20] do Add( s, i^2 ); od; s;</span>
[ 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400 ]
</pre></div>

<p>Note that a range with <code class="code"><var class="Arg">last</var> >= <var class="Arg">first</var></code> is at the same time also a proper set (see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>), because it contains no holes or duplicates and is sorted, and also a row vector (see <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a>), because it contains no holes and all elements are integers.</p>

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

<h5>21.22-1 IsRange</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsRange</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>tests if the object <var class="Arg">obj</var> is a range, i.e. is a dense list of integers that is also a range (see <a href="chap21.html#X79596BDE7CAF8491"><span class="RefLink">21.22</span></a> for a definition of <q>range</q>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange( [1,2,3] )""gapgt< java.lang.StringIndexOutOfBoundsException: Range [62, 60) out of bounds for length 128

true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange( [1 .. 3] );</span>
true
<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

false
< class=GAPprompt">ap&;/span><span class=GAPinput"IsRange( [] );  IsRange( [1] );</span>
true
true
</pre></div>

<p><a id="X83896BC481536B07<>Developers wishto  thisfor custom list collection needto install suitablemethodsfor  operation c class="ode"ForAnyOp<code>.<p>

<h5>21.22-2 IsRangeRep</h5>

<class"func"<table class=func"width="100%"><tr><td class="tdleft"><code class="func">&#yle='color: green'>8227; IsRangeRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">( representation )</td></tr></table></div>
T =><var  represented as  , that is by internally storing   first value,the in-or decrement,  the lastvalue ofthe java.lang.StringIndexOutOfBoundsException: Range [177, 176) out of bounds for length 181

<p>To java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 6

<p>Lists created by the syntactic construct <code class="code">[ <var class="Arg">first</var>, <var class="Arg">second</var> .. <var class="Arg">last</var> ]</code>, see <a href="chap21.html#X79596BDE7CAF8491"><span class="RefLink">21.22</span></a>, are in <code class="func">IsRangeRep</code>.</p>

<Note  ifyou java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 476


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRangeRep( [1 .. 3] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRangeRep( [1, 2, 3] );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [1..3];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l[1] := 1;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l;</span>
    
</pre></div>

<>=" name="X7D22B2298167A58F>/a>p>

<h5>21.22-3 ConvertToRangeRep</h5>

<div class"unc>< =unc"width=100"<>=""code =f"&8227;;ConvertToRangeRep</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For some lists the java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0

<p>If <var class="Arg">list</var> is a range then <code class="func">ConvertToRangeRep</code> changes the representation of <var class="Arg">list</var> to <code class="func">IsRangeRep</code> (<a href="chap21.html#X83896BC481536B07"><span class="RefLink">21.22-2</span></a>). A call of <code class="func">java.lang.StringIndexOutOfBoundsException: Range [0, 322) out of bounds for length 0


<div<>java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 160
<span class="GAPprompt">gap></span> <span class="GAPinput">r:= [ 1, 2, 3, 4, 5,
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">ConvertToRangeRep( r );  r;</span>
[ 1 .. 10 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ 1, 2, 4, 5 ];;  ConvertToRangeRep( l );  l;</span>
[ 1, 2, 4, 5 ]
</pre></div>

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

<h4>21.23 <span class="Heading">Enumerators</span></h4>

<p>An <em>enumerator<em>isanimmutable list that neednot store its elements explicitly but knows, from a set of basic data, how to determine the <span class="SimpleMath">i</span>-th element and the position of a given object. A typical example of this is a vector space over a finite field with <span class="SimpleMath">q</span> elements for which it is very easy to enumerate all elements using <span class="SimpleMath">q</span>-adic expansions of integers.</p>

<p>Using this enumeration can be even quicker 

<p>On the one hand, element access to an enumerator may take more time than element access to an internally represented list containing the same varclass=Arg"list</var

<p>There are situations where one only 

<p>The functionspCalled java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 284

<>Alsoenumerators fornon-domains java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 294

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

<</h5java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

<div class="func"><table class="func" width="100%"><tr><p<aD  wishjava.lang.StringIndexOutOfBoundsException: Range [40, 36) out of bounds for length 164
<p>This filter indicates that a position test in <var class="Arg">list</var> is quicker than about 5 or 6 element comparisons for <q>smaller</q>. If this is the case it can be beneficial to use <code class="func">Position</code> (<a 

<p><a id="<div class="func<table class="funcwidth100%>tr>td "tdleft"><codeclass="&8227;ListN</ode<classGjava.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 111

<>21.24 <java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

<p>Plain lists are the default java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

<pTypicalwhere the representation matters are when one wants to make sure that the given list is <em>not</em> a plain list and thus will be handled more efficiently, for example when one installs a method for a particular operation, where an argument is required to be a list in a particular representation.</p>

<>< ""java.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 62

<. PlainListCopy<5java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; java.lang.StringIndexOutOfBoundsException: Range [0, 114) out of bounds for length 0
<p[ 4 6 ]

<p><a id="X87BA4EBF80F16B72

<pre>div>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsPlistRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&java.lang.StringIndexOutOfBoundsException: Index 177 out of bounds for length 5
<p><strong class="pkg">GAP</strong> lists created by entering comma separated values in square brackets are usually represented internally as so-called <em>plain lists</em>. Other representations of lists are <code class="func">div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap20.html">[Previous Chapter]</a>    <a href="chap22.html">[Next Chapter]</a>   </div>


<div class="example"><pre>
<"">apgt;<>span class=""I([1 ,3];/pan>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlistRep( "abc" );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlistRep( [ 1 .. 5 ] );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlistRep( BlistList( [ 1 .. 5 ], [ 1 ] ) );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlistRep( 0 );</span>
false
</pre></div>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap20.html">[Previous Chapter]</a>    <a href="chap22.html">[Next Chapter]</a>   </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="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

Messung V0.5 in Prozent
C=99 H=99 G=98

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.304Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Diese beiden folgenden Angebotsgruppen bietet das Unternehmen

Angebot

Hier finden Sie eine Liste der Produkte des Unternehmens






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1128594
#Domains=1976912