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


< version1.0" "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</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div

<p id="mathjaxlink" class="pcenter"><aspan=>gt;</pan<class">IsTable  [1] [23]] ;       # not   atable</span>
<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"java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ <var class="Arg">list</var> )</td><td class="tdright">( property )</td></tr></table></div>
<span "ContSS">br/<nocss&;;/span< href"html#java.lang.StringIndexOutOfBoundsException: Range [105, 104) out of bounds for length 141
<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>
<spanclass=ContSS>br >spanclass"" &<span>< =chap21#>21.1-6 IsConstantTimeAccessList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7B202D147A5C2884java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</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>
<java.lang.StringIndexOutOfBoundsException: Range [10, 4) out of bounds for length 25
<span class="ContSS"><br /><span class="nocss"> <><id"" name""<<p
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"h4.<class""BasicOperationsforLists/span/>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&p basic  forlists elementaccess(see< href"h#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 java.lang.StringIndexOutOfBoundsException: Index 278 out of bounds for length 0
< class"ContSS"< />span="">nbsp </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>
< class="ContSS</<span ="nocss>nbsp;nbsp<span< href"java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 130
</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>
<java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 7
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </div="func>class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ <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></<iv class="<java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 274
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 0
<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 p><code class=""\\] varArg>list<>,varclass=></var> )</code isequivalent  code ="< class""listvar> var class""var ]/code>, clearly will usually be preferred; the former is useful mainly if one wants to access the operation itself, for example if one wants to install a method for element access in a special kind of lists.</p>
<
<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">Comparisonsp>Analogous  hold for< class""<span>/span><\<span>\\<codeand<code =func"Unbind<></pan><span></span>]</code>.</p>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.htmlh4213<span class="Heading">List Elements</span></h4>
</span>
</div>
<div class="ContSect"><span class="tocline"><span<><code =""<varclass="">list</var> var class""<>]code<p
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X87ABCEE9809585A0">21.12-1 IsGeneralizedRowVector</a></spanjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<pan="ContSS"<>spanclass=nocss>;&;</span> href".X7FBCA5B58308C158>.-2IsMultiplicativeGeneralizedRowVector/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<pre<div>
</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 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
</span>
<divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
<divclass"ContSect"<java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 191
<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</ 7]
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X84FDB95179BFE4CD">21.14-pre<div
</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 java.lang.StringIndexOutOfBoundsException: Range [0, 33) out of bounds for length 32
</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="java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 0
<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">  < class"Arg"pos/var]<code  code class=code"<var ="poss<java.lang.StringIndexOutOfBoundsException: Range [142, 141) out of bounds for length 343
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7B4B10AE81602D4E">21.16-3 PositionCanonical</a></span>
<span class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<panclass="ontSS"br/><span class""> nbsp;/span>a href=chap21.tml#>.16-PositionSorted<a<span
<span class="ContSS"><br /><span class=l[pos1]{}poss3}[pos4]{poss5}[pos6]
<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">/pre></div>
<span class="ContSS"><br /><span
<span class="ContSS"><br /><span class="nocss">  </span><a <p>Then a selector < class=code>var ="Arg"list<var>[class=Arg"pos<var]<code> of level<varclass="Arg"level</var> is computed as <code class="code">ListElement(<var class="Arg">list</var>,<var class="Arg">pos</var>,<var class="Arg">level</var>)</code>, where <code class="code">ListElement</code> is defined as follows. (Note that <code class="code">ListElement</code> is <em>not</em> a <strong class="pkg">GAP</strong> function.)</p>
<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="java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 33
<span class="ContSS"</spanjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
<div></>
<div <span>
</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="">nbsp&;span>a href="chap21.#X84BB2DFB8432A1A4">21.14-6 <span class="Heading">Left quotients of lists</span></a>
<span =
<span class=""br/""&;<>a =chap21
<span<>/
<<java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
""&>href".tml#X79596BDE7CAF8491">21.22 <span class="Heading">Ranges</span></a>
/>
<div class="ContSSBlock">
spanC"br/classnocss"&;nbsp</a"java.lang.StringIndexOutOfBoundsException: Index 146 out of bounds for length 146
span"<span class="ContSS"
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap21.html#X7D22B2298167A58F">21.22-3 ConvertToRangeRep</a></span>
<div>/div>
<iv class""<pan ""spanclass=""&</span< ="chap21.java.lang.StringIndexOutOfBoundsException: Range [167, 115) out of bounds for length 167
<
<div class="ContSSBlock">
spanclass">br/< class""><iv class="ample><re
<><div>
<div class="    class""< >span class"ocss"&;nbsp<span< =chap21.#X86C9E5C3863B3C03">21.16-11 PositionBound</a></span>
<
<div class="ContSSBlock">
="nocss"> ;/>ahref=chap21html#X8438CB908367254C">21.24-1 PlainListCopy</a></span>
<span class="<span class="ContSS> >s"ocss"nbsp;nbsp;/>ahref".#X7F42E5AD87EC9D5A">21.16-14 PositionNonZero</a></span>
<div><divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
</<ivclassContSect< class""<span =ocss>nbsp;span< =chap21.#X7865747A7CCF5812">21.17 <span class="Heading">Properties and Attributes for Lists</span></a>

<h3>21 <span class=<pan class""<  class">< class"rg><var>< "">pos</>]=< =<</a></span>

<>Listsare  most  way treat java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 12

<p>This chapter deals mainly with/>

<p>Lists are used to <span class="ContSS"><br /><span>nbsp  list[s =;

<p>Severalelse

<  for<  class=>< > class=nocss>nbsp&<>ahref=java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 136

<h4>anjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

span=ContSS"< >span =nocss"&bsp&<span>a href="chap21.html#X7B4C0FEE7CDF6F2A">21.19-2 IsEqualSet</a></span>fi;


<div class="example<pan class=ContSS"< /span=""&bsp;nbsp;/< hrefjava.lang.StringIndexOutOfBoundsException: Range [0, 81) out of bounds for length 12
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ];              # a list with three elements</span>"/> =< ="><<code>f java.lang.StringIndexOutOfBoundsException: Range [148, 147) out of bounds for length 543
 ,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  isjava.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 133

<>a=X7C4CC4EA8299701Ename"  =als;

<h5>21.1-1 IsList</h5>

<div class="func"><table class="func" ""< /<class="nocss&bsp&;/java.lang.StringIndexOutOfBoundsException: Range [0, 65) out of bounds for length 54
<p>tests whether <var class="Arg"< classContSS> >span=nocss"&&;<span>a=".tml


<div class="example"><pre>
<span< ="<br/<class="ocss>nbsp&<span<<span class="ContSS"><br /><span class="nocss">  </span><a
rue

/<div>

p< idX870AA9D8798C93DD5>code>21.-\\}=code><h5java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37

<h5>21.1sclass=ContSS>br< ""class"width100>>tdclass=tdleft>cclass=">&#8227; \{\}\:\=</code>( <var class="Arg">list</var>, <var class="Arg">poss</var>, <var class="Arg">val</var> )</td><td class="tdright">( operation )</td></tr></table></div>

<div class="func">< class"""%>trt =tdleft"< =f"&8227 /> v "Arg>< <<djava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<<class""<""&;nbsp<java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 174


<> > ""&;&<<".htmljava.lang.StringIndexOutOfBoundsException: Index 134 out of bounds for length 134
""ap;/>s class=GAPinput>IsDenseList  ,2 ;/pan>
true
< ""gapgt;<span s =GAPinput> :=[, 4,<addselement< ""obj<>   listvar=""<The  adds<class=>obj/>atthe  of< ="Arg>list/var i.e. it  java.lang.StringIndexOutOfBoundsException: Index 213 out of bounds for length 0
false
n&java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 130
9
<span class="GAPprompt">gap></span> <span class="GAPinput">< 
 Element&l;4must an 
not < ">br/<pan class="ocss"&&;/pan><
<h5>214-Remove<java.lang.StringIndexOutOfBoundsException: Index 183 out of bounds for length 183
you cans java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
you can 'return<span =">br/<class the removedelement.In this case <var class="Arg">list</var> must be non-empty.</p>
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">l[4] := 16;;  # assigning a value</span>
<span class<pThetwoargument  <>
16
gap>
</pre></div><>

pbserve   ode"">l[4<code,whichnot  the   <class"></code-(   ".#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< =ContSS>br >class">nbsp/>java.lang.StringIndexOutOfBoundsException: Range [142, 68) out of bounds for length 142

<h5>21.1-3 IsHomogeneousList</h5>

<[2, < =ContSS> /< ">nbsp&<span>hrefhap21#X7BB462C17962647F">21.23-1 IsQuickPositionList</a></span>
<r code class=spanclass=GAPprompt>></><class=GAPinput>(,2) l<span>

<p>A class""br/<class"ocss>nbsp&bsp;span< href=chap21html#X8438CB908367254C">21.24-1 PlainListCopy</a></span>


class""rejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<span class="GAPprompt">gapjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
true
true
<span class="GAPprompt">gap&<spanclass<p>Listsarethemost way   togetherAemlistem   in definiteorderSolist from to    e is  ofa,a,a  soon  can  immutableformseeahref"html
false
</pre></div>

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

<h5>21.1-4 IsTable</h5>

<div  codeclassjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
p >tableem is  list  homogeneouswhichlieinthe  family.Typicalexamplesof (ee a =".html#X812CCAB278643A59"><span class="RefLink">24</span></a>).</p>


<div
<span =GAPprompt"gapgt</> span class=GAPinput" theoperations < =unc>/ <a href=chap21.java.lang.StringIndexOutOfBoundsException: Range [318, 152) out of bounds for length 318
true
<span class="<p>A list can be writtenbywriting down the elements  order <p>A list can be written by writing down the elements in order between
true
<spanclass=GAPprompt>gap>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
false
/pre>/java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12

<p><a id [     ] ,2< class"">tableclass""width=100%>tr<d "<>divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

1 java.lang.StringIndexOutOfBoundsException: Range [31, 29) out of bounds for length 34

<div class=
>  in class"">/> itis    elements homogeneouslistsof the samepwhether<var"Arg><>  <pjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

"""<>/

<>116 IsConstantTimeAccessList/h5>

div=func"< ==func"=100">trtdclass"">codeclass"func"&8227; IsConstantTimeAccessList</code>( <var class="Arg">list</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p<span "gapgt</pan <panclass="APprompt"g>/>< =GAPinput"(l,[, 23  )l</>[ 2 3,5,7 11 13 , 23]

<p>But also other enumerators (see <a href="chap21.html#X7EA3ACE27E43D174"><span class="RefLink">21.23</span></a>) can lie in this category if they guarantee constant time access to their elements.</p>

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

<h4>21.2 <span class="Heading">Basic Operations for Lists</span></h4>

 forlists  elementaccess(< "h#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> inany java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

mbasicoperation name""<a<p>

<p>Any <strong class="pkg">java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0

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

p< id=div=func<class""width="%>tr< =tdleft>code=func>#8227; IsBound</code>( <var class="Arg">list</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( operation )</td></tr></table></div>

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

 =func>tableclass=funcwidth"%>div java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 26
<span="gapgt<span < "IsHomogeneousList [ ,2   ;  ([ )<spanjava.lang.StringIndexOutOfBoundsException: Index 128 out of bounds for length 128
<div class="func"><pan class""<> =>([ 1 false (]);/pan
p< id"X80872FAF80EB5DF9"name"">/a>p>
<<>.4IsTable/h5>

<p>Note that the special characterss class=GAPprompt>&<span> <pan =GAPinput"IsBound [101])<span>

<p><code class="code">\[java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

<p>Similarly, <code 

<p>Analogous statements hold for <code class="func"><span>\</span>[<span>\</span>]\:\=</code> and <code class="func">Unbind<span>\</span>[<span>\</span>]</code>.</p>

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

<h4>21.3 <span class="Heading">List Elements</span></h4>

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

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


<div class="example"><pretrue
<span class="GAPprompt">gap>< class="APprompt">></span> <span class=<div class="func"><table class="func" width="100%"><tr><td"""code classf>8227 GetWithDefault</ode( varclass=>list<var,varclass"Arg"n<var> <ar classArg"default/>)td>td class=tdright> &)/td<>/table</ivjava.lang.StringIndexOutOfBoundsException: Index 283 out of bounds for length 283
2
3
13


> <class""list<>    -java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

pc =ode>var=list/>  ""/java.lang.StringIndexOutOfBoundsException: Range [78, 77) out of bounds for length 91

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


<divclass=example"><>
<span class="GAPprompt">gap></<span class=GAPprompt">gap></span> <span class="GAPinput">l := [1,2,,"a"];</span>
span ="GAPprompt"gapgt<span>< class=GAPinput">l{[4..6]};  l{[1,7,1,8]};</span>
[ 7, 11, 13 ]
[ ,17,2,19]
</pThis categoryindicates  the  toeach element of  <ar ="list<var>[,2,"java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

pTheresult  class="GAPprompt">&;span>span="Gjava.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 98

<<


<>      element access see< href.#"ajava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
classjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 137

<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ [ 7, 8, 9 ], [ 4, 5,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<re>div>

<p< =true

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


<div class="examplediv""<tableclass"func" width"100%>tr><dclass=tdleft><class"">&='color:green'>#8227; <span>\</span>[<span>\</span>]</code>( <var class="Arg">list</var>, <var class="Arg">ix</var> )</td><td class="tdright">( operation )</td></tr></table></div>
    l[pos1]{poss2}{poss3}[p< =unc"<class" width=100"tr>=tdleft"codeclass="func">#
level   0      0      1     2< ="func"><table class="func" width="100%">tr<td class=tdleft"<codeclass"func"&8227&nbsp;<span\/span>[<span>\<span<code(
</pre></div>

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


<div class="example"><pre>
ListElement<codeclass""Unbindcodedeleteselementindex<arclass=rg><>in list< class"Arg"list/var>  is,afterexecution of code class=func>Unbind</ode, var =""></var>no  hasanassigned value withindex <arclassjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 
  return list[pos];
 else
  return List( list, elm -> ListElement(elm,pos,level-1) );
 fi;
end;
</pre></div>

pandaselector < => =Arg"/>{<varclass""possjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
 level )
  level =0then
  return list{poss">prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  else
   return List( list, elm -> java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  fi;pIfvar=Arg" 2,,,7,,11 java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
end;
<pre>/divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<><a <Notethat< =func><code a =chap21.tml#X79EC565A7DCEC938"><span class="RefLink">21.5-1</span></a>) and <code class="func">Unbind</code> are special in that they do not evaluate their argument, otherwise <code class="func">IsBound</code> (<a href="chap21.html#X79EC565A7DCEC938"><span class="RefLink">21.5-1</span></a>) would always signal an error when it is supposed to return <code class="keyw">false</code> and there would be no way to tell <code class="func">Unbind</code> which component to remove.</p>

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

<div class="func"><table class="<p>The result is a <em>new</em> list that is not identical toany other java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<> nest  emextractionsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<<java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 26

<h4>21.4 <span class="Heading">java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 32

  7, 8, 9 ],  i : 3java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

>  assigns theobjectvarclassArg><var>,whichcan  java.lang.StringIndexOutOfBoundsException: Range [97, 96) out of bounds for length 465


<div class="example"><pre>
ap&<span> <panjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
s class"">>/ < java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ 3, 2, 3
<span lass=example><rejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
[ 3, [ 4, 5, 6 ], 3 ]
spanclass=>paselector<class""<Arg><varvclassrg>/><>   ""level<var> iscomputedas<ode class=code"ListElement<ar class=Arg"<var,varclass=Arg"><var><class"Arg"level<var><<>>
[ 3, [ 4, 5, 6 "<<Thejava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 234
</pre></div>

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


dclass=example"><>
<span class="return List( list, elm&;java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 62
[ 3, [ 4, 5, 6 ], 10, "
<class""java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[
/re/>

<p if   

<> assigningre

> varclassArglist/>   toa list < class"">pos/>  not  toapositiveintegermethodselection is invokedjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

<p><code class="code"><var class="Arg"><pre><div>

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


<div class=h4214span class"> Assignment/span<>
<span class="<>codeclass=>var =Arg>list</var>[< class=Arg"ix/>]: var class""object/var;/code>pjava.lang.StringIndexOutOfBoundsException: Index 123 out of bounds for length 123
< java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ 10, 11, 12, 13, 11, 13, 17, 19 ]
< class=GAPprompt">gapgtl1:=  1 ;
[ 3,spanclass"">gap><span span "l[1 =3;:l1
//>

<p>The next example shows that it is 


<div class="example"><pre>
<span class=
span""gap;/pan> span class="java.lang.StringIndexOutOfBoundsException: Range [66, 63) out of bounds for length 124

</pre></ ,[,, ,," entry]

<p>The exact behaviour is [ 3, [ 4, 5, 6 ], 10, "another en"<Ifyou      thelistdenoted  this literal  a  listthat not identical  any list.Thus inthe following <ode ""l1  code=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
      assigning  a list the ,  mutables < =chap12h#X7F0C119682196D65"><span class="RefLink">12.6</span></a>). See <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a> for subtleties of changing lists.</p>
0            1     1       2
</pre></div>

<<pThe  assignment assigns  object codeclass="ode"< class="Arg"<>lso  the  example,nolists the < class""l/ode  .</p>


<div class="example"><pre>
ListAssignment := function ( list, pos, vals, level )
 local i
 iflevel=0 
  list[pos] := vals;
 else
 iin[.Length)] do
   ListAssignment(listi],pos, vals[i], level-1 );
  od;
 fi;
endjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
</pre></div>< class=example"><pre

<p>and a list assignment <code class="code"><var class="Arg">list</var>{<var class="Arg">poss</var>} := <var class="Arg">vals</var></code> of level java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


divclass=example"<>
ListAssignments := function ( list, poss, vals, level )
 local i;
 if level = 0 then
  list{poss} := vals;
 else
  for i in [1..Length(list)] do
   ListAssignments( list[i], poss, vals[i], level-1 );
  od;
 fi;
end;
</pre></div>

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

<h5><code>21.4-1 \{\}\:\=</code></h5>

<div class="func"><table class="func" width="100%"><tr><td class="java.lang.StringIndexOutOfBoundsException: Range [0, 72) out of bounds for length 0
<p>This operation implements sublist assignment. For any list,l1 : [1 2 ]

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

<h5>21.4-2 Add</h5>

<div class=
<p>adds the element <var class="Arg"><pIfyouchangea   keepsitsidentity. Thus iftwo  are identical and you change ofthem,youalsochange the other,andtheyare still identical afterwards.Onother ,  lists that are not identical will never become identical if you change one of them. So in the following example both <code class="code">l1</code> and <code class="code">l2</code> are changed, and are still identical.</p>

<p>The three argument version adds <var class="Arg">obj</var> in position <var class="Arg">pos</var>, moving all later elements of the list (if any) up by one position. Any holes at orjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Nothing is returned by <code class="func">Add</code>, the function is only called for its side effect.</p>

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

<h5>21.4-3 Remove</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><>< id=X7D7C0738495556F" name="X7ED7C0738495556F"></a></p>
<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<>heoneargument returns .thiscase<var ="rg>ist<var>non-empty.<pjava.lang.StringIndexOutOfBoundsException: Index 124 out of bounds for length 124

<p>The two argument form returns the old value of <p   meaning<ode"func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) and <code class="func">StructuralCopy</code> (<a href="chap12.html#X7C1E70587EBDD2CB"><span class="RefLink">12.7-2</span></a>) for lists. For the general definition of these functions, see <a href="chap12.html#X786B942B82D684BD"><span class="RefLink">12.7</span></a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5 ];; Add( l, 7 ); l;</span>
[ 2, 3, 5, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Add(l,4,2); l;</span>
[ 2, 4, 3, 5, 7 ]
<span class="java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
4
[ 2, 3, 5, 7 ]
<span </pre></div
7
[2 3 5]
<span class="GAPprompt">gap></span> <span class="GAPinput">Remove(l,5); l;</span>
[ 2, 3, 5 ]
</pre></div>

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

<h5>21.4-4 CopyListEntries</h5>

<div class="func"><table class="func" width="100   ListAssignment(list[i], pos,vals[i] level1)
<p>;

p =func><codeisused  methodsfortheoperations code class=func><code =c.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 <iv ="xample"><pre>

21-<

<div  level=0 then
<ListAssignments(list[i, i], level- );

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


<div classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<pan ="APprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5 ];; Append( l, [ 7, 11, 13 ] ); l;</span>
[ 2, 3, 5, 7, 11, 13 ]
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 2,3 5 7 11,13, 17, 23 ]
</pre></div>

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

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

<p><a id="

<h5>21.5-1 IsBound</h5>

 class"func"width""<><tdclass="tdleft">codeclass="func"&#8227; IsBound</code>( <var class="Arg">list</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
p< ="">IsBound</returns<code =keyw"true/code>ifthe  <arclass"Arg>list<var  anelement at index < class=Arg"n</var> and<code class="eyw>false/>otherwise <var class="Arg>list<var> must evaluate to a list,or   object  which suitable method for code class="code>IsBound[]/code has been ,  an error issignalled</


<div class="example"<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
span class=GAPprompt>gap&t</pan <panclass="GAPinput">l := [ , 2, 3, , 5, , 7, , , , 11 ];;</span>
<span class="GAPprompt">gap></span> <<>a id="X7E98B11B79BA9167" name="X7E98B11B79BA9167"<a<
rue
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBound(< class=func>tableclass"" width"100%>tr<td=tdleft>codeclass="func"‣ Remove</code>( <var class="Arg">list</var>[, <var class="Arg">pos</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
false
<
false
</pre></div>

p< "" =">a>p>

<h5>21.5-2 GetWithDefault</h5>

< class=func>tableclass=func" =100">tr< class=tdleft< class=func>#8227;GetWithDefault</> var class="Arg">list</var>, <var class="Arg">n</var>, <var class="Arg">default</var> )</td><td class="tdright">( operation )[2 3,5,7]
<p><code class="func">GetWithDefault</code> returns the <var class="Arg">n<span class"APprompt"gapgt<span <pan ="GAPinput">emove(l,);l;<span>

<p>While this method can be used on any list, it is particularly useful for Weak Pointer lists <a href="chap86.html#X86D963DC7968899B"><span class="RefLink">86.1</span></a> where the value of the list can change.</p>

 distinguish between the < class=""></> elementbeing unbound, or< =Arg"default</var> being in <ar class"">list</var>, userscan createa new mutable object such as a string. codeclass="func"IsIdenticalObj/> (a ="chap12#">spanclass=RefLink">12.-1/pan>/>  < class""false<code  java.lang.StringIndexOutOfBoundsException: Range [394, 393) out of bounds for length 443


classexample">java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<">gap></span> <span class="GAPinput">l := [1,2,,"a"];</span>
[ 1, 2,, "a" ]
<span class="GAPprompt">gap></span> <span class="GAPinput">newobj := "a";</span>
"a"
<span class="GAPprompt">gap></span> <span class="GAPinput"><div class"">class""width"100%><r>< =">code class="func">&#8227; CopyListEntries</code>( <var class="Arg">fromlst</var>, <var class="Arg">fromind</var>, <var class="Arg">fromstep</var>, <var class="Arg">tolst</var>, <var class="Arg">toind</var>, <var class="Arg">tostep</var>, <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">GetWithDefault(l, 3, newobj);</span>
"a"
<span class=GAPprompt>gapg;<span spanclass"GAPinput">etWithDefault(l, 4, newobj);</span>
"a"
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(GetWithDefault(l, 3, newobj), newobj);</span>
true
<span class="GAPprompt">p>aid"X79E31DB27C82D6E1" name=X79E31DB27C82D6E1>/>/java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
false
</pre></div>

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

h>.5-3 Unbind</>

<div class="func"><table class="func" width="100%"><tr><<p>adds the elements of the list <var class="Arg">list2</v the  of the mutable  varclass"Arg></var ahref=".#X8611EF768210625B"><span class="RefLink">21.4</span></a>. <var class="Arg">list2</var> may contain holes, in which case the corresponding entries in <var class="Arg">list1</var> will be left unbound. <code class="func">Append</code> returns nothing, it is only called for its side effect.</p>
<p><code class="func">Unbind</code> deletes the element with index <var class="Arg">n</var> in the mutable java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>

<ivclass=example">pre
[ ]
< l[4] ); l;</span>
[ , 2,,,, 7,,,, 11 ]
</pre></div>

<p>Note <java.lang.StringIndexOutOfBoundsException: Range [22, 5) out of bounds for length 97

<p><a id="X7DD65BEA7EDB0CD7" name="java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 31

<h4>21.6 <span class=<pre</iv>

<p>With the list assignment (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>) it is possible to change a mutable list. This section describes the semantic consequences of this fact. (See also <a href="chap12.html#X84545F3985C60F5B"><span class="RefLink">12.5</span></a>.)</p>

<p>First we define what it means when we say that <q>an object is changed</q>. You may think that in the following example the second assignment changes the integer.</p>


<div class="example"><pre>
i := 3;
i := i + 1;
</pre>/>

<p>But in this example it is not the <em>integer</em> <code class="code">3</code> which is changed, by adding one to it. Instead the <em>variable</em> <code class="code">i</code> is changed by assigningthe  of <codeclass=""i+</ode>  happens to be <code class="code"4<code>, <ode =code">i/ode>.The thing in theexample below.</p>


<div class="example"><pre>
l := [ 1, 2 ];
 :  ]java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
<pre>/div>

<p>The second assignment does not change the first list, instead


<div class="example"><pre>
l:   ;
l[3] :span class=GAPprompt">&<span> span class">( [7 ;span>
</pre></div>

p> understandthedifference, think of avariableas anameforan object Theimportantpointisthat  listcanhaveseveralat the same time An assignment <code class="">var =Arg>var<var>=<var classArg></var;</code>meansin this interpretation that var =Arg>var/ a namefor theobject< ""list<. of following<code class="class"ode"l2/>stillhas  java.lang.StringIndexOutOfBoundsException: Range [452, 451) out of bounds for length 566


<iv>>
l1 := [ 1, 2 ];
l2 := l1;
l1 := [ 1, 2, 3 ];


> the   the   <=l/   has andthustheof< ">l2 ,3 </code></>


<div class="example"><pre>
l1 := [ 1, 2 ];
l2 := l1;
l1[3] := 3;
</<p>Todistinguish  var class"">/varthelement ,<""varbeing< ""var> can  a new object such string codeclass=func>IsIdenticalObj<code < =chap12.#X7961183378DFB902"><span class="RefLink">12.5-1</span></a>) returns <code class="keyw">false</code> for different mutable strings, even if their contents are the same.</p>

<p>We<iv class=""<pre>

<p> 1, 2,a 

<p>Ifa"


<div class="example"><pre>
l1 =[1,  ;
l2 := [ 1, 2 ];
</pre></div>

<p>Also in the following example, no lists in the list <code class="code">l</code> are identical.</p>


<div class="example"><pre>
l := [];
for i in [1..10] do l[i] := [ 1, 2 ]; od;
</pre></div>

<p>If you assign a list to a variable no new list is created. Thus the list value of the variable on the left hand side and the list on the right hand side of the assignment are identical. So in the following example <code class="code">l1</code> and <code class="code">l2</code> are identical lists.</p>


<div class="example"><pre>
l1 := [ 1, 2 ];
l2 : l1;
</pre></div>

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


< example>pre>
l1 := [ 1, 2 ];
f := function ( <div class=examplepre>
l2 := f( l1 );
</pre></div>

<p>  ,2, ,  ]


 java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 26
l1 := [ 1, 2 ];
l2 := l1;
l1[1] <h4>21. span =">java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 22
/>/

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

<h4>21.7 <span class="Heading">Duplication of Lists</span></h4>

<p

pThesubobjects(see<5<21.-- i<</>

<p>This means that for any list <varjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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

>In ,modifyingthecopy varclass=Argn<var resp.< Arg">scp<var  assignments( a href=html#X8611EF768210625B"><span class="RefLink">21.4</span></a>) does not modify the original object <var class="Arg">list</var>.</p>

<pnew: [;


<div class="example"><  if IsBound( list[i] ) th( i)then
new := [];
for i in [ 1 .. Length( list ) ] do
  if class"GAPprompt"gapgt< class">1   2, 2 1 3]  1in java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    new[i] := list[i];false
  java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 5
od;
</pre></div>


<div class="java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ [ 1, 2 ], [ 3, 4 ] ];;  list2  [1,2][3java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
s<>21< classHEnlargingLists>/>
false
<span class="GAPprompt">gap&<pSection< java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
rue
pan=GAPprompt>>span span class=>[]:=0; ;  list2;span>
[ [ 1, 2 ], [ 3, 4 ] ]
[   []: StructuralCopylist[ )
<re>/>

<p><code


<div class="example"><pre>
 : [;
for i in [ 1 .. Length( list ) ] do
IsBoundi)
    new[i] := StructuralCopy( list[i] );
  fi;
od
<pre>/divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12


<div class="example"><pre>
<span class="GAPprompt">gap<>Theabove<>.1EmptyPlist<h5>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj( list1[1], list2[1] );</span>
false
<span class="GAPprompt"<<"">&t</ class"> =java.lang.StringIndexOutOfBoundsException: Range [96, 85) out of bounds for length 102
[ [ 1, 2 ], [ 3, 4 ] ]
[ [ 0, 2 ], [ 3, 4 ] ]
</pre></div>

>  code class=func><codegives to strong =""GAP/trong'   the physical   allocated  the plain list <var class="Arg">l</var> but not needed by the current number of entries.</p>


<div class="example"><pre>
ass
<span class="GAPprompt">gap>
[ [ 1, 2 ], [ 1, 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">list2[1][1] := 0;; list2;</span>
[ [ 0, 2java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
<span class="GAPprompt">gap></<span class="GAPprompt">gap></span=java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 125
[ ,    ]java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22


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

<4>21. span class"eading">MembershipTest forLists<span></4>

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

h><code>2181 \<code>/h5>

djava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
<p>This function call or the infix <p>Two lists <var class="Arg">list1</varand< =Arg>>      forindexsclassSimpleMath>span   java.lang.StringIndexOutOfBoundsException: Range [171, 170) out of bounds for length 523

<p<<div>


<div class="example"><pre>
<span classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
true
false
<span<>21. <pan class=Heading>EnlargingInternally Represented Lists<span<h4>
<span class="GAPprompt">gap></span> <span class="GAPinput">17 in s;  # uses binary search and only 4 comparisons</span>
false
</prespan =GAPprompt>&<span><pan "> 1 ,3 ]   3, 2, 1]<span>

<p>For finding the position of an element

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

<h4>21.9 <span class="java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<<pOn otherhand  every assignment beyondjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<Sothefollowingstrategyisused  a createdjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0

p the/    any .java.lang.StringIndexOutOfBoundsException: Range [104, 103) out of bounds for length 1003

<p>So the following strategy is used. If a list is created it is created with exactly the correct size<

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

<> that< "">/code (a =

pFor fine tjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

<p><a id="

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

"width=100%>tr<td class="dleft
<p>Returns:<>thatfor lists  <ode code"lt<code>or code <>eturns: nothing</p>

<div class="func<> function <code class=func"><a id="X845EEAF083D43CCE" name="X845EEAF083D43CCE
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<</code>returns empty plain list which has java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 code"func"<>givesjava.lang.StringIndexOutOfBoundsException: Range [77, 74) out of bounds for length 263

Nthere functions code class""/ode>(a =chap27.#X836078DC829A8221>spanclass"java.lang.StringIndexOutOfBoundsException: Index 139 out of bounds for length 0


 ""java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
 ""gg;/>"";pan">l:=[:=]; for i in [1..160] do Add(l, i^2); od;</span>GEmptyPlist160;.] m ^;od<>
[  ]
G"gapgt<>span<span class="GAPprompt">gap></span> <span class
[  ]class""><span<pan
span=GAPprompt>g<span spanclass="GAPinput"># now l uses about 25% more memory than the equal list m</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ShrinkAllocationPlist(l);</span>
<span class="GAPprompt">gap><<><aid"X8016D50F85147A77" name=<p><a id="X84D642967B8546B7" name="X84D642967B8546B7a></java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
</pre></div>

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

<h4>21.10 <span class

<

pcode"< ""list1</>&t&t <ar java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 0

<d =<>


d java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 26
span=GAPprompt>gap>/ span class=GAPinput[1, , 3]=[,2,3]<span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">[ , 2, 3 ] = [ 1, 2, ];</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ] = [ 3, 2, 1 ];</span>
false
</pre></div>

 own   two such lists for equalitymay     if list has java.lang.StringIndexOutOfBoundsException: Index 202 out of bounds for length 0

<p><code class="code"><var class="Arg">list1</var> < <var class="Arg">list2</var></ <>istsem/ java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 1003

<>code =code>varclass=Arg>list1< lt= var">list2/var>/><pjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96

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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[<pan class="GAPprompt">gap></span> <span class="GAPinput">IsMultiplicativeGeneralizedRowVector( liemat );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ] < [ 1, 2, 3, 5 ];  # <list1>[4] is unbound and thus < 5</span>
true
spanGAPpromptgap</span> =GAPinput> 1  ,4 ] <  ,-,3]# &list1[]is unbound thus &;-1<span>
true
</pre></div>

>thatfor  two <""&;/>(elevant be codeclass"">lt</>   usually e>not/> the for   different families,see  href=chap13.#X846063757EC05986><span =RefLink131/<a.Alsofor  to compare   other objects see < =chap13.java.lang.StringIndexOutOfBoundsException: Range [499, 455) out of bounds for length 499

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

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

<pNotethe""(to generalityflexibility  definitionsgiveninthefollowingsectionsare  technical Butfor complicated  suchas  (ee < href"chap24.html#X7899335779A39A95"><span class="RefLink">24.3</span></a>) and row vectors (see <a href="chap23.html#X85516C3179C229DB"><span class="RefLink">23.2</span></a>) whose entries aren't lists, the resulting behaviour should be intuitive.)</p>

<p>(Due to the intended generality and flexibility, the definitions given in the following sections are quite technical. But for not too java.lang.StringIndexOutOfBoundsException: Index 146 out of bounds for length 0

<p>For example, we want to deal with matrices which can be added and multiplied in the usual way, via the infix operators <code class="code">+</java.lang.StringIndexOutOfBoundsException: Index 147 out of bounds for length 0

<p>For the categories and attributes that control the arithmetic behaviour of lists, see <a href="chap21.html#X84D642967B8546B7"><span class="RefLink">21.12</span></a>.</p>

<p>For  definition   valuesofadditiveand  whose   listsin  filters  a ="hap21.tmlX7E6A1F66781BE923"><span class="RefLink">21.13</span></a> and <a href="chap21.html#X782ED7F27D8C7FC1"><span class="RefLink">21.14</span></a>, respectively. It should be emphasized that these sections describe only what the return values are, and not how they are computed.</p>

<

<p> classjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 26

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

h>. <pantrue

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

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

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

</h5

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


<div class
< ""gapgt;/pan "gapgt;/< class=GAPinput>();  java.lang.StringIndexOutOfBoundsException: Range [99, 97) out of bounds for length 111
true
false
 class">&;/s
LieObject([  1 ] java.lang.StringIndexOutOfBoundsException: Range [24, 0) out of bounds for length 0
<span class="GAPprompt">gap></span<> a<strongclass=pkg>GAP/>  < class=Arg>/> <odeclass=func"NestingDepthA</ the<emadditivenesting <em  < class""obj/>        spanclassSimpleMath<> class/    classfunc>java.lang.StringIndexOutOfBoundsException: Range [351, 350) out of bounds for length 816
true
/></java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12

pa=X7FBCA5B58308C158"name"></<p>

<h5>21.12-2 IsMultiplicativeGeneralizedRowVector</h5>

lass"">table ="func"width=100"<tr<class"tdleft"<code class=func>‣ IsMultiplicativeGeneralizedRowVector</code>( <var class="Arg">list</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>For a list <var class="Arg">list</var>, the value <[ [ 1, -2 ] -3 ]


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMultiplicativeGeneralizedRowVector( liemat );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">bas:= CanonicalBasis( FullRowSpace( Rationals, 3 ) );</span>
CanonicalBasis( ( Rationals^3 ) )
<span class="GAPprompt">gap&
true
</pre></div>

<p>Note that the filters <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>), <code class="func">IsMultiplicativeGeneralizedRowVector</code> do <em>not</em> enable default methods for addition or multiplication (cf. <code class="func">IsListDefault</code> (<a href="chap21.html#X7BAD12E67BFC90DE"><span class="RefLink">21.12-3</span></a>)).</p>

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

<h5>21.12-3 IsListDefault</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; IsListDefault</code>( <var class="Arg">list</var> )</td><td class="tdright">( category )</td></tr></table></div>
<>For< class"Arg">list</var>, <code class="func">IsListDefault</code> indicates that the default methods for arithmetic operations of lists, such as pointwise addition and multiplication as inner product or matrix product, shall be applicable to <var class="Arg">list</var>.</p>

<p><code class="func">IsListDefault</code> implies <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>).</p>

<p>All internally represented lists are in this category, and also all lists in the representations <code class="code">IsGF2VectorRep</codejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">v:= [ 1, 2 ];;  m:= [ v, 2*v ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsListDefault( v );  IsListDefault( m );</span>
true
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsListDefault( bas );  IsListDefault( liemat );</span>
rue
false
</pre></div>

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

<h5>21.12-4 NestingDepthA</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; NestingDepthA</code>( <var class="Arg">obj</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>For a <strong class="pkg">GAP</strong> object <var class="Arg">obj</var>, <code <span class="GAPprompt">gap></span> <span class="GAPinput">l1:= [ 1, , 3, 4 ];;    ,,4,];/span>

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

<h5>21.12-5 NestingDepthM</h5>

<">‣ NestingDepthM</code>( <var class="Arg">obj</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>For a <strong classjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1


<class"java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 26
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( v );  2
1
1
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( m );  NestingDepthM( m );</span>
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( liemat );  NestingDepthM( liemat );</span>
2
0
<span class="GAPprompt">gap></span> <span class="GAPinput">l1:= [ [ 1, 2 ], 3 ];;  l2:= [ 1, [ 2, 3 ] ];;</span>
<span class="APprompt">gap&<span span class""NestingDepthA( l1)  NestingDepthM( l1 );</span>
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l2 );  NestingDepthM( l2 );</span>
1
1
</pre></div>

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

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

<p>In this general context, we define the results of additive operations only in the following situations. For unary operations (zero and additive inverse), the unique argument must be in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>); for binary operations (addition and subtraction), at least one argument must be in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>), and the other either is not a list or also in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</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">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>), it shall be left to this argument whether the result in question is defined and what it is.)</p>

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

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

<p>The[  1, 2 ,[3,4], [ 10,12 ]]


<div class="example"><<p>For two <strong classpkg></strong> objects <span class="SimpleMath">x</span> and <span class="SimpleMath>y</span> ofwhich  is <code class"func><code < ".java.lang.StringIndexOutOfBoundsException: Index 564 out of bounds for length 564
<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>

>  inversesee<class""/>< =java.lang.StringIndexOutOfBoundsException: Index 532 out of bounds for length 532


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

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

<h5>21.13-3 <span class="Heading">Addition of lists</span></h5>

<p>If <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> are in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#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>If <span class="SimpleMath">x</span> is in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and <span class="SimpleMath">y</span> is in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and has lower additive nesting depth, or is neither a list nor a domain, the sum <span class="SimpleMath">x + y</span> is defined as a list whose entry at position <span class="SimpleMath">i</span> is <span class="SimpleMath">x[i] + y</span> if <span class="SimpleMath">x</span> 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 summands is kept, as addition is not always commutative.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">1 + [ 1, 2, 3 ];  [ 1, 2, 3 ] + [ 0, 2, 4 ];  [ 1, 2 ] + [ Z(2) ];</span>
[ 2, 3, 4 ]
[ 1, 4, 7 ]
[ 0*Z(2), 2 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l1:= [ 1, , 3, 4 ];;             l2:= [ , 2, 3, 4, 5 ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l3:= [ [ 1, 2 ], , [ 5, 6 ] ];;  l4:= [ , [ 3, 4 ], [ 5, 6 ] ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l1 );  NestingDepthA( l2 );</span>
1
1
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l3 );  NestingDepthA( l4 );</span>
2
2
<span class="GAPprompt">gap><
[ 1, 2, strongp<aid" ="<java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 62
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 + l3;</span>
[[2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="GAPinput"< "">&;/<pan =GAPinputO [1  34 ];>
[ , [ 3, 6, 3, 4, 5 ], [ 5, 8, 3, 4, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l3 + l4;[[7,8] [[3, 6 ]  ]]
[ [ 1, 2 ], [ 3, 4 ], [ 10, 12 ] ]
<<ivclass=""<>
 ]
/pre></div>

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

<h5<>aid"X7A0FD70C80B95C00" name="X7A0FD70C80B95C00"></a></p>

<p>For two <strong class="pkg">GAP</strong> objects <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> of which one is in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#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="example"><pre>
 class">><span> <spanclass=GAPinput">l1  l2;/>
[ 1, -2, 0, 0, -5 ]
<> <span class=GAPinput> - 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 ="GAPprompt">gap><span> <span class=GAPinput>  ;<span>
[ [ 1, 2 ], [ -3, -4 ], [ 0, 0 ] ]
<<classexample>pre>
[ 1,, 3< "">&;/span><spanclass"APinput>LeftQuotient( [[1 2 ], [ 3  ] ], [1 2 ] )</span>
</pre></div>

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

<h4>21.14 <span class="Heading">Multiplicative java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0

<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 onejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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

<5>2114- span class"eading>Onefor </span><java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59

p  see<codeclassfunc>/>(<a =chap31html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>)) of a dense list <var class="Arg">x</var> in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) such that <var class="Arg">x</var> has even multiplicative nesting depth and has the same length as each of its rows is defined as the usual identity matrix on the outer two levels, that is, an identity matrix of the same dimensions, with diagonal entries <code class="code">One( <var class="Arg">x</var>[1][1] )</code> and off-diagonal entries <code class="code">Zero( <var class="Arg">x</var>[1][1] )</code>.</p>


<div class="example"><pre>
span =""gap></span> <spanclass=GAPinput"One [[1 2 ] [ 3,4   );<span>
[ [ 1, 0 ], [ 0, 1 ] ]
<span class="GAPprompt">gap></span> <span class
[[  [1  ] [[0  ]],[[  0]] [   ] ] ] ]
</pre></div>

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

<h5>21.14-2 <span class="Heading">Inversespan=gap;span  =>l1);  IsMutable  *Immutable([1 2  ]));<span>

<p>The inverse


<div class="example"><pre>
<class">>/><span class="GAPinput">Inverse( [ [ 1, 2 ], [ 3, 4 ] ] );</span>
[ [ -2, 1 ], [ 3/2, -1/
</pre><pAn  use of syntactic constructs suchas<codeclass"code">< "">obj/ * var""<codeclass">< ""listvar<code   andefficient waytocreate listsneeded further frommutablelists.particular  constructamutablezero  oflengthspan=SimpleMath">n</span> by <code class="code">0 * [ 1 .. </code><span class""n/span>code"" <code. The canbedone < ""></code>(< href=chap21.html#X80FDB1457FF582E7"><span class="RefLink">21.15-1</span></a>).</p>

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

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

<p>There are three possible computations that might be triggered by a multiplication involving a list in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>). Namely, <span class="SimpleMath">x * y</span> might be</p>


<dl>
<dt><strong classclass">pre>
dd<>innerproduct <span class="impleMath>[]y x]*y]+⋯x]*yn</span>  summands are  forwhich  entry  span "SimpleMath></span>or span=""></>is unbound(leavesno  the java.lang.StringIndexOutOfBoundsException: Range [287, 284) out of bounds for length 305

</dd>
d>strongclass"">L)/strong>/>
<dd<returns  ofthe occurrence < =Arg><var in<var =Arg>list<var>  <code class="keyw>fail/>if< class"Arg><var notcontained  <class=Arg"list/var.Ifastarting  v ""from/var is given,   the    firstoccurrence   search emafter<em  <ar class="Arg><./p>

</>
<java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
<dd><p>the right scalar multiple, i.e., a list whose entry at position <span class="SimpleMathjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

</dd>
</dl>
rize the situations that shall  covered./>

<div class="pcenter"><table class="GAPDocTable">
<tr>
<td class="tdcenter"></td>
<td class="tdcenter/pre<div>
<td class="tdcenter">vec</td>
<td class="tdcenter">mat</td>
<tr
<tr>
<td class="tdcenter">scl</td>
<td class="<h5>21.16-2 Positio</h5>
<td class="tdcenter">(L)</td>
<td class"tdcenter">(L)</td>
</tr>
<tr>
< class"tdcenter"vec/d>
<td class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<td class="tdcenter">(I)</td>
<td class="tdcenter">(I)</td>
</tr>
<tr>
<td class="tdcenter">mat</td>
<td class="tdcenter">(R)</td>
<td class="tdcenter">(R)</td>
< class"tdcenter"()/
</tr>
</table><br />
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 6

<p>This means for example that the product<>aid=X7B4B10AE81602D4E name=X7B4B10AE81602D4E>/>/p

<p>Now we can state the general java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 34

<>   argument in< ="">IsMultiplicativeGeneralizedRowVector/>(ahref"chap21.#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) then we regard the other argument (which is then neither a list nor a domain) as a scalar, and specify result (L) or (R), depending on ordering.</p>

pIntheremaining ,both< =""x<span> < =""><>arein<code class=func>IsMultiplicativeGeneralizedRowVector/code> <chap21htmlX7FBCA5B58308C158"<span =RefLink>21122/span<a>) and  distinguish  possibilities by their multiplicative nesting depths. An argument with <em>odd</em> multiplicative nesting depth is regarded as a vector, and an argument with <em>even</em> multiplicative nesting depth is regarded as a scalar or a matrix.</p>

<p>So if both arguments have odd java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0

<> oneargumenthas oddnesting depth the other istreated asa scalarifit has  multiplicative nesting depth,and as a matrix otherwise. In the former case,wespecify result()or(R,onordering thelatter case,  result Lor() dependingon ./>

<p>We are <span class=">gapgt<span>s class"">:=ightTransversalgu;;r);/>


<div class="example"><pre>
s "">gapgt<span><span "GAPinput" ) (,)1,2, (,,3),13,),(3)] 14;/>
[ (1,4),spanclass=""gapgt<span <pan ""PositionCanonical(t,,2)<>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, , 4 ] * 2;</span>
[ 2, 4,, 8 ]
<span p><a id="X7D2B25B484591506name=X7D2B25B484591506"></a></p>
22
<span class="GAPprompt">gap></span> <span class="GAPinput">m:= [ [ 1, 2 ], 3 ];;  h5.164PositionNthOccurrenceh5
[ [ 7, 8 ], [ [ 3, 6 ], 9 ] ]
=>&<span>< =GAPinput> m=m] *m m[2]* m]/>
true
<span class="GAPprompt">java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
14
=GAPprompt"gapgt;/span <spanclass"GAPinput"n *n = n[1]  n1]+ n2 *n2;/spanjava.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
true
< =GAPprompt&<java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 112

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

<>.- < class"Heading">of lists/span><>

<p>For two <strong class="pkg">GAP</strong> objects <span class=


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ] / 2;  [ 1, 2 ] / [ [ 1/>/java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
[ 1/2, 1, 3/2 ]
[ 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 << class""<tableclass""width=100"<>td class=tdleft"<codeclass=func>#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>

pIf spanclass=><span   code "">sMultiplicativeGeneralizedRowVectorcode < =chap21.tml


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">4711 mod [ 2, 3,, 5, 7 ];</span>
[ 1, 1,, 1, 0 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 2, 3, 4, 5, 6 ] mod 3;</span>
[, 0,1, , java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
<span class="GAPprompt"gapgt;/>span ""[,, 14,  mod[ ,5, 7 ];</java.lang.StringIndexOutOfBoundsException: Range [104, 103) out of bounds for length 104
[ 1, 2, 0, 16 ]
</pre<div>

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

<h5>21.14-6 <span class="<>Developers who to this  custom typesto java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 157

<p>For two <strong class="pkg">GAP</strong> objects <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> of which one is in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and the other is also in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) or is neither a list nor a domain, <code class="code">LeftQuotient( <var class="Arg">x</var>, <var class="Arg">y</var> )</code> is defined as <span class="SimpleMath">x^{-1} * y</span>.</p>


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

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

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

<p>Many results of arithmetic operations, when applied to lists, are again lists, and it is of interest whether their entries are mutable or not (if applicable). Note that the mutability status of the result itself is already defined by the general rule for any result of an arithmetic operation, not only for lists (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>).</p>

<p>However, we do <em>not</em> define exactly the mutability status for each element on each level of a nested list returned by an arithmetic operation. (Of course it would be possible to define this recursively, but since the methods used are in general not recursive, in particular for efficient multiplication of compressed matrices, such a general definition would be a burden in these cases.) Instead we consider, for 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>), the sequence <span class="SimpleMath">x = x_1, x_2, ... x_n</span> where <span class="SimpleMath">x_{i+1}</span> is the first bound entry in <span class="SimpleMath">x_i</span> if exists (that is, if <span class="SimpleMath">x_i</span> is a nonempty list), and <span class="SimpleMath">n</span> is the largest <span class="SimpleMath">i</span> such that <span class="SimpleMath">x_i</span> lies in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>). The <em>immutability level</em> of <span class="SimpleMath">x</span> is defined as infinity if <span class="SimpleMath">x</span> is immutable, and otherwise the number of <span class="SimpleMath">x_i</span> which are immutable. (So the immutability level of a mutable empty list is <span class="SimpleMath">0</span>.)</p>

<p>Thus a fully mutable matrix has immutability level <span class="SimpleMath">0</span>, and a mutable matrix with immutable first row has immutability level <span class="SimpleMath">1</span> (independent of the mutability of other rows).</p>

<p>The immutability level of the result of any of the binary operations discussed here is the minimum of the immutability levels of the arguments, provided that objects of the required mutability status exist in <strong class="pkg">GAP</strong>.</p>

<p>Moreover, the results have a <q>homogeneous</q> mutability status, that is, if the first bound entry at nesting depth <span class="SimpleMath">i</span> is immutable (mutable) then all entries at nesting depth <span class="SimpleMath">i</span> are immutable (mutable, provided that a mutable version of this entry exists in <strong class="pkg">GAP</strong>).</p>

<p>Thus the sum of two mutable matrices whose first rows are mutable is a matrix all of whose rows are mutable, and the product of two matrices whose first rows are immutable is a matrix all of whose rows are immutable, independent of the mutability status of the other rows of the arguments.</p>

<p>For example, the sum of a matrix (mutable or immutable, i.e., of immutability level one of <span class="SimpleMath">0</span>, <span class="SimpleMath">1</span>, or <span class="SimpleMath">2</span>) and a mutable row vector (i.e., immutability level <span class="SimpleMath">0</span>) is a fully mutable matrix. The product of two mutable row vectors of integers is an integer, and since <strong class="pkg">GAP</strong> does not support mutable integers, the result is immutable.</p>

<p>For unary arithmetic operations, there are three operations available, an attribute that returns an immutable result (<code class="func">Zero</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>), <code class="func">AdditiveInverse</code> (<a href="chap31.html#X84BB723C81D55D63"><span class="RefLink">31.10-9</span></a>), <code class="func">One</code> (<a href="chap31.html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>), <code class="func">Inverse</code> (<a href="chap31.html#X78EE524E83624057"><span class="RefLink">31.10-8</span></a>)), an operation that returns a result that is mutable (<code class="func">ZeroOp</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>), <code class="func">AdditiveInverseOp</code> (<a href="chap31.html#X84BB723C81D55D63"><span class="RefLink">31.10-9</span></a>), <code class="func">OneOp</code> (<a href="chap31.html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>), <code class="func">InverseOp</code> (<a href="chap31.html#X78EE524E83624057"><span class="RefLink">31.10-8</span></a>)), and an operation whose result has the same immutability level as the argument (<code class="func">ZeroSameMutability</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>), <code class="func">AdditiveInverseSameMutability</code> (<a href="chap31.html#X84BB723C81D55D63"><span class="RefLink">31.10-9</span></a>), <code class="func">OneSameMutability</code> (<a href="chap31.html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>), <code class="func">InverseSameMutability</code> (<a href="chap31.html#X78EE524E83624057"><span class="RefLink">31.10-8</span></a>)). The last kind of operations is equivalent to the corresponding infix operations <code class="code">0 * <var class="Arg">list</var></code>, <code class="code">- <var class="Arg">list</var></code>, <code class="code"><var class="Arg">list</var>^0</code>, and <code class="code"><var class="Arg">list</var>^-1</code>. (This holds not only for lists, see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>.)</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutable( l1 );  IsMutable( 2 * Immutable( [ 1, 2, 3 ] ) );</span>
true
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutable( l2 );  IsMutable( l3 );</span>
true
true
</pre></div>

<p>An example motivating the mutability rule is the use of syntactic constructs such as <code class="code"><var class="Arg">obj</var> * <var class="Arg">list</var></code> and <code class="code">- <var class="Arg">list</var></code> as an elegant and efficient way to create mutable lists needed for further manipulations from mutable lists. In particular one can construct a mutable zero vector of length <span class="SimpleMath">n</span> by <code class="code">0 * [ 1 .. </code><span class="SimpleMath">n</span><code class="code"> ]</code>. The latter can be done also using <code class="func">ListWithIdenticalEntries</code> (<a href="chap21.html#X80FDB1457FF582E7"><span class="RefLink">21.15-1</span></a>).</p>

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

<h5>21.15-1 ListWithIdenticalEntries</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; ListWithIdenticalEntries</code>( <var class="Arg">n</var>, <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>is a list <var class="Arg">list</var> of length <var class="Arg">n</var> that has the object <var class="Arg">obj</var> stored at each of the positions from <code class="code">1</code> to <var class="Arg">n</var>. Note that all elements of <var class="Arg">lists</var> are identical, see <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a>.</p>


<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>

<p>Each call to the two argument version is translated into a call of the three argument version, with third argument the integer zero <code class="code">0</code>. (Methods for the two argument version must be installed as methods for the version with three arguments, the third being described by <code class="code">IsZeroCyc</code>.)</p>


<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">Position( [ 2, 1, 1, 3 ], 1 );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">Position( [ 2, 1, 1, 3 ], 1, 2 );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">Position( [ 2, 1, 1, 3 ], 1, 3 );</span>
fail
</pre></div>

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

<h5>21.16-2 Positions</h5>

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

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


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

<p><a id="X7B4B10AE81602D4E" name="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>returns the position of the canonical associate of <var class="Arg">obj</var> in <var class="Arg">list</var>. The definition of this associate depends on <var class="Arg">list</var>. For internally represented lists it is defined as the element itself (and <code class="func">PositionCanonical</code> thus defaults to <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>), but for example for certain enumerators (see <a href="chap21.html#X7EA3ACE27E43D174"><span class="RefLink">21.23</span></a>) other canonical associates can be defined.</p>

<p>For example <code class="func">RightTransversal</code> (<a href="chap39.html#X85C65D06822E716F"><span class="RefLink">39.8-1</span></a>) defines the canonical associate to be the element in the transversal defining the same coset of a subgroup in a group.</p>


<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> returns <var class="Arg">pos</var> such that <span class="SimpleMath"><var class="Arg">list</var>[<var class="Arg">pos</var>-1] < <var class="Arg">elm</var> ≤ <var class="Arg">list</var>[<var class="Arg">pos</var>]</span> holds. That means, if <var class="Arg">elm</var> appears once in <var class="Arg">list</var>, its position is returned. If <var class="Arg">elm</var> appears several times in <var class="Arg">list</var>, the position of the first occurrence is returned. If <var class="Arg">elm</var> is not an element of <var class="Arg">list</var>, the index where <var class="Arg">elm</var> must be inserted to keep the list sorted is returned.</p>

<p><code class="func">PositionSorted</code> uses binary search, whereas <code class="func">Position</code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>) can in general use only linear search, see the remark at the beginning of <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>. For sorting lists, see <a href="chap21.html#X83E558E37D1B44D4"><span class="RefLink">21.18</span></a>, for testing whether a list is sorted, see <code class="func">IsSortedList</code> (<a href="chap21.html#X7BAA9B0E81D4A884"><span class="RefLink">21.17-3</span></a>) and <code class="func">IsSSortedList</code> (<a href="chap21.html#X80CDAF45782E8DCB"><span class="RefLink">21.17-4</span></a>).</p>

<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 <span class="SimpleMath"><var class="Arg">func</var>(elm) = <var class="Arg">val</var></span> holds, then the position of the first such element is returned. If no element of <var class="Arg">list</var> satisfies this condition, then the lowest index where an element <var class="Arg">elm</var> satisfying <span class="SimpleMath"><var class="Arg">func</var>(elm) = <var class="Arg">val</var></span> must be inserted to preserve the property <code class="code">func(list[i]) <= func(list[i+1])</code> is returned.</p>

<p><code class="func">PositionSortedBy</code> uses binary search. Each <code class="code">func(list[i])</code> is computed at most once.</p>

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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], -1, Length );</span>
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
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], 2, Length );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionSortedBy( [ "", "ab", ], 3, Length );</span>
3
</pre></div>

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

<h5>21.16-7 PositionSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionSet</code>( <var class="Arg">list</var>, <var class="Arg">obj</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">PositionSet</code> is a slight variation of <code class="func">PositionSorted</code> (<a href="chap21.html#X7A122E848464E534"><span class="RefLink">21.16-5</span></a>). The only difference to <code class="func">PositionSorted</code> (<a href="chap21.html#X7A122E848464E534"><span class="RefLink">21.16-5</span></a>) is that <code class="func">PositionSet</code> returns <code class="keyw">fail</code> if <var class="Arg">obj</var> is not in <var class="Arg">list</var>.</p>


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

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

<h5>21.16-8 PositionMaximum</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; PositionMaximum</code>( <var class="Arg">list</var>[, <var class="Arg">func</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; PositionMinimum</code>( <var class="Arg">list</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<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 classjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
3
<span class="GAPprompth521.- java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 33
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionMinimum( [2,4,-6,2,4], x -> -x);</span>
2
</pre></div>

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

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

<h5>21.16- /h5

 ="table="unc" ="100%<tr><d "tdleft>code class=func>#;PositionProperty/>(<<var> <td><class"tdright"(no&bsp)/td>/>table><div>
<p


<div class="example"><pre>
<span class=java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
20
<span
span"GAPprompt"&;/>< class""        -;not IsPrime()andIsPrimePowerInt(n )<span>
490
</prejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

< =""<classf"width="100"<>td=""< class">#8227; /> v class=Arg><var> < class=A><var>,<class=Arg"funcvar>] )/td<class=tdright">&;functionnbsp;<td<tr>/table>/java.lang.StringIndexOutOfBoundsException: Index 280 out of bounds for length 280

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

h521.- <h5>

div=>table=func width=%"tr>tdclass=tdleft>c class="func">‣ 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>
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="">&;/>< classGAPinput4711mod  2,3, ,7]<span>
[ 7, 8, 9, 10, 11 ]
< class""gapgt<span span "">ositionsProperty l  );/pan>
[
</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< =""name""></><java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>21.16-11 PositionBound</h5>

divclass=f>tableclass=func "100"<>td =tdleft"< class"">#java.lang.StringIndexOutOfBoundsException: Index 224 out of bounds for length 224
<p>returns the first bound java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 12


<div class="example"><pre>
<span class="GAPprompt"<  of arithmeticoperationswhenappliedtolists,again andit ofinterest     mutable  i applicable)  that  mutabilitystatus of result   alreadydefined thegeneral  for of   operation   forlists( a=chap12html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>).</p>
1
="GAPprompt>gap></span><span =GAPinput>PositionBound([,1,2,3]);</span>
2
</pre></div>

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

<h5>

class=func"< class=" width="%"<tr><dclass="tdleft"><code class="func">&#8227; PositionsBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all


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

<<div class="example"><pre>

<h5>21.16-13 <span class="GAPprompt"gap>/span> < class=GAPinput"IsMutable(l1     *Immutable([ 1 2, 3 ]  );/>

func>tableclass="" width="100%">tr<td class="tdleft"><code class="func">&#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/pre></>


<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"



<<div2115-1 ListWithIdenticalEntries</h5>
<java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0

<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 


<div class="/java.lang.StringIndexOutOfBoundsException: Range [212, 211) out of bounds for length 692
<span class="GAPprompt">gap></span> <span class="GAPinput">PositionNonZero( [ 1, 1, 2, 3, 2 ] );</span>
java.lang.StringIndexOutOfBoundsException: Index 176 out of bounds for length 1
<span class="GAPprompt">gap></span> <span class="<521.- ConstantTimeAccessList/
2
</pre></div>

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

<h5>21.16-15 PositionSublist</h5>

<div class="func"><java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<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>

stead.</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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:=[[1],[2]];</span>
[ [ 1 ], [ 2 ] ]
<span(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 java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 836

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

<h5>21.17whether java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 364

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsMatchingSublist</code>( <var class="Arg">list</var>, <var class="Arg">sub</var>[, <var class="Arg">at</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns <

<p>If you 4AddSet/5java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

a =java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62

<h5>21.17-2 IsDuplicateFree</h5>

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

<p>A list is <em>duplicate free</em> if it is dense and does not contain equal entries in different positions. Every <=java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 89

<</strong> b java.lang.StringIndexOutOfBoundsException: Range [92, 91) out of bounds for length 253

<p><a id="java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 22

<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="java.lang.StringIndexOutOfBoundsException: Index 170 out of bounds for length 0
<>eturns <ode class=keyw"true</code>if <ar class"">bj<var>isa   it is sorted, and <ode class=keyw"false<code>./>

<p>A list <var class="Arg">list</var> is <em>sorted</em> if it is dense (see <code class="func">IsDenseList</codejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Many sorted lists are in fact homogeneous (<p>removes the element <var class="Arg">obj</var>class"java.lang.StringIndexOutOfBoundsException: Range [86, 85) out of bounds for length 389

<p>In sorted lists, membership test and computing of positions java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 0

<p>Note that <strong class="pkg">GAP</strong> cannot compare < =GAPprompt"g></span spanclass"GAPinput":=[2,3,4,5,,7];/pan>

<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 < , 3 4,5 7  ]
<p>returns <code class="keyw">true</code> if <var class="Arg">obj</var> is a list and it is strictly sorted, and <java.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 91

<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 java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 0
<java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 114

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

<h5>21.17-6 ConstantTimeAccessList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft">< "func"<set<var> < classclass">ar /java.lang.StringIndexOutOfBoundsException: Range [184, 183) out of bounds for length 251
p> "func">ConstantTimeAccessList</code> returns an immutable list containing the same elements as the list <var class="Arg">list</var> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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

<h4>21.18 <span class="Heading">Sorting java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<implementsdifferentjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 781

>id=

<h5>21.18-1 Sort</h5>[ 6,1,4 7,5 5]

<ivclass=func<
<div class="func"><table class
<div class="func"><table class="java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 26
>#8227 <><arclass="rg>list<>,varArg>nc<> )td>tdclasst"(n;operation&;)/td>/r><table><>
<p><code class="func">Sort</code><"java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 105

<p><code class="func">StableSort</code> behaves[1 2],[1,3 , [0,4 ],[, ] [1[2 3, , , 7 8 911

<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.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) if you want to keep <var class="Arg">list</var>. Use <code java.lang.StringIndexOutOfBoundsException: Index 304 out of bounds for length 127

<codeclass"S</code   list < =Arg"list/var  an   that <class""func(i)&; ([+]<code  all relevant var ="rg><> <var class="rg></ar>must   a function on oneargumentwhich returns  that becompared  <<p><code class="func">SortBy</code> sorts the list <var class="Arg">list</var> into an order such that <code class="code">func(list[i]) <= func(list[i+1])</code> for all relevant <var class="Arg">i</var>. <var class="Arg">func</var> must thus be a function on one argument which returns values that can be compared. Each <code class

<p><code class="func">StableSortBy</code> <p>Several of the following functions expect theGAPinput> note  randomorder   elements with equal first :<>


<div class="example"><pre>
<panclass"">apg;/span> <pan =G"list =[5,,6 ,  ;   ; ;/java.lang.StringIndexOutOfBoundsException: Index 119 out of bounds for length 119
[ 1, 4, 5, 5, 6, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">SortBy(list, x -> x mod 3);</span>
<spanclass="GAPprompt">gap></span> <span class="GAPinput">list; # Sorted by mod 3</span>
[, 7, 5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">list := [ [0,6], [1,2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
spanclassG">gapgt;<s><pan ="Sort(list,functionvw returnvv l; w*; end )</>
<span class="GAPprompt">gap></span> <span class="GAPinput">list;  # sorted according to the Euclidean distance
[ 1 2]  1 3][0,4 ,[,4]  1,  ] [,6  ]
<span class="GAPprompt">gap></span> <span class="GAPinput">SortBy( list, function
<span <p>Notethat <class=func"Concatenation</code> creates a new list and leaves its arguments unchanged, while <code class="func">Append</code> (<a href="chap21p>codeclass="func>SortParallel<code>sorts the list <var class="Arg">list1</var> in
[ [ 1, 2 ], [ 1, 3 ], [ 0, 4 ], [ 1, 5 <iv class="example"<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<G"gapggt<span> <span class="GAPinput">list := [ [0,6], [1,3], [3,4], [1,5], [1,2], [0,4] ;<span>
<span class="GAPprompt">gap></span> <java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 17
<span class="GAPprompt">gap
<span class="GAPprompt">gap></span> <span class="java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 37
 s =GAPprompt"gapgt;/span><pan class=GAPinput>list1 :=[5,,6,1 7,5];/span>
</pre></div>

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

<h5>21.18-2 SortParallel</h5>

<div class="func"><table java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 0
< class""nc">able =unc"=100>tr>< class"""code class=func"&8227;code> < class=Arg></ar>, <var class="Arg">list2</var>[, <var class="Arg">func</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">SortParallel</code> sorts the list <var class="Arg">list1</var> in increasing<iv class="func"><table class="func" width="100%"><tr><td java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 20

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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ 5, 4, 6, 1, 7, 5 ];</re>/
<span class="GAPprompt">gap></span> <span class="GAPinput">list2 := [ 2, 3, 5, 7, 8, <>a ="7<
<span class="GAPprompt">gap></span> <span class="GAPinput">SortParallel( list1, list2 );</span>
<span class<>21.20- </5java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
[ 1, 4, 5, 5, 6, 7 ]
span =GAPprompt>&</span><span class="APinput>;/>
[ 7, 3, 2, 9, 5, 8 ]
</pre></div>

<p>Note that <code class=pF   java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 130

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

<h5>21.18-3 Sortex</h5>

<class">gapg;/ s ">(last);/panjava.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
<java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 663

<p><code class="func">Permuted</code> (<a href="chap21.html#X7B5A19098406347A"><span class="RefLink">21.20-17</span></a>) allows you to java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ 5, 4, 6, 1, 7, 5 ];;</span>
<span class=p>aid"<ivclassfunc">table classfunc"width=100%>tr< class">codeclass"func&tyle='color: green'>8227 java.lang.StringIndexOutOfBoundsException: Range [120, 118) out of bounds for length 228
<span class="GAPprompt">gap></span> <span class="GAPinput">perm := Sortex( list1 );</span>
(1,3,5,6,4)
<span class="GAPprompt">gap></span> <span class="GAPinput">list1;</span>
[ 1, 4, 5, 5, 6, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Permuted( list2, perm );</p< =func"SortingPerm<code java.lang.StringIndexOutOfBoundsException: Range [48, 4) out of bounds for length 26
[ 1, 4, 5, 5, 6, 7 ]
</pre></div>

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

<h5>21.18-4 SortingPerm</h5>

<div class1 Z3,abc" [(,,) (1, class=APpromptgap&;/span  "APinput"erm  : ortingPerm( list1 )/span>
<p><code class="func">SortingPerm</code> returns the same as <code class="func">Sortex</code> (<a href="chap21.html#X87287FCA81E2B06A"><span class="RefLink">21.18-3</span></a>) but does <em>not</em> change the argument.</p>


<div class="example"><pre>
=GAPprompt><span> class"java.lang.StringIndexOutOfBoundsException: Range [62, 60) out of bounds for length 100
<panclass="GAPprompt"gap&<ass=func"width"><td=dleft< ==unc>#;AsDuplicateFreeListcode> v class=Arg>list<v>)/>td =tdright"(nbsp;ttribute&bsp)/>t>/able>/div>
<span class="GAPprompt">gap></span> <span class="GAPinput">perm := SortingPerm( java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 12
(1,3,5,6,4)
<span
[5,4, 6 1, 7, ]<>< id=X80ABC25582343910"name=X80ABC25582343910"/>/pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
<span class="GAPprompt">gap></span> <span
[ 11,,5,5,6,7 ]
</pre></div>

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

<h4>21.19 <span class="Heading">java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0

<p>Searching objects in a list works much quicker if the list is known to be sorted. Currently <strong class="pkg">GAP</strong> exploits the sortedness of a list automatically only if the list is <em>strictly sorted</em>, which is indicated by the property <code java.lang.StringIndexOutOfBoundsException: Index 268 out of bounds for length 263

<p>Remember that a list of <em>mutable</em> objects cannot store that it is strictly sorted but has to test it anew whenever it is asked whether it is sorted, see the remark in <a href="chap21.html#X7865747A7CCF5812

<p>Strictly<iv ">pre>

 by  java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 263

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

<p>This section lists[  ]

<p>There are nondestructive counterparts of the functions <code class="func">UniteSet</code> (<a href="chap21.html#X7B3469CD7EFC1A87"><<p>o reconstruct a matrix the list obtainedby applying<ode class="func">Flat</code> to the matrix, the sublist operator can be used, as follows.</p>

<The  cjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 1020

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

<><>.- i<>[[9 10 ,[ ,12],[13   

<iv="unc"<java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 239
<p>For a list <var class="Arg">list</var> that stores that it is strictly sorted, the test with <code class="func">\in</code> whether the object <var class="Arg">obj</var> java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

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

<h5>21.19-2 IsEqualSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
<p>tests whether <var class="Arg">list1</var> and <var class="Arg">list2</var> are equal <em>when viewed as sets</em>, that is if every element<div =func"<able class"=tdleft><ode funcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsEqualSet( [2,3,5,7,11], [11,7,5,3,2] );</span
true
<panclass">ap&<s span =GAPinput"IsEqualSet [2,35711],[235,1113 ;/>
false
</pre></div>

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

<h5>21.19-3 IsSubsetSet</h5>

 class="func" width=100"<tr>td class=tdleft"<code class=func">&#8227; IsSubsetSet</code>( <var class=<5>21.19-3 IsSubsetSet</h5>
<tests every elementof <java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 364

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

<h5>21.19-4 AddSet</h5>

<div class="func[1 .20 java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
pjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 369

<p="func><able ="func"=1001,2,10 9 17, 9,


<class"">pre>
s "">apg;/ < class=""s: [,,,11]</>
<span class[19divclass=e">prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
[ [e/>
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 2,, ,,11,  ]
<spanclass=GAPprompt
[ 2, 3, 5, 7, 11, 13 ]
<pre</iv>

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

<h5>21.19-5 RemoveSet</h5>

<div funcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>removes <21.-RemoveSet<h5>


< "java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 12
< class=GAPprompt>><span><<p><a id="X7EF6E2BC81DBF6FB" name="X7EF6E2BC"></>/p>
<span class="GAPprompt">gap></span> <span class="GAPinput">RemoveSet( s, 6 
[ 2, 3, 4, 5, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">RemoveSet( s, 10 ); s;</span>
 ,,,5  
</pre></div>

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

<h5>[23  <class>pre

X"name"X7B3469CD7EFC1A87>/>/>
<p>unites the proper set <var class="Arg">set</var> with <var class="Arg">list</var>. This is java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 1


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">set := [ 2, 3, 5, 7, 11 ];;</span>
<>120-11 </>
[ 2, 3, 4, 5, 7, 8, 9, 11 ]
<span class="GAPprompt"gap&;<span><span  class="GAPinput>( set,[16,9,25,ength(<var class="Arg">list1</var> ) ]</code> such that <var class="Arg">list1</var><span class="SimpleMath">[i</span><code class="code">^</code><span class="SimpleMath">p] =</span> <var class="Arg">list2</java.lang.StringIndexOutOfBoundsException: Range [0, 299) out of bounds for length 0
 ,,4,5, ,8,9,,13 , ]
</div

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

<h5>21.19-7 IntersectSet</h5>

<div class="func"><table class="func" width="100%"><tr
<p>intersects the proper set <var class="Arg">set</var> with <var class="Arg">list</var>. This is equivalent to removing from <var class="Arg">set</var> all elements of <var class="Arg"


java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 113
< ="GAPprompt"gap&;</span> <span class=GAPinput">IntersectSet( set, <>Inthe 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</var> ≥ <var class="Arg">obj1</var></9]
[ ,5 7 ,11  ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IntersectSet( set, [ 9, 4p<<
[ 9 ]
</<h5>21>119- SubtractSet</h5>

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

<h5>21.19-8 SubtractSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code <p>subtracts <var class="Arg">list</var> from the proper set <var class="Arg">set</va
<p>subtracts <var class="Arg">list</var> from the proper<ivclass=example"<pre>


< =example"<re>
<span class="GAPprompt">gap></span> <span class="GAPinput">set := [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">SubtractSet( set, [ 6, 10 ] );  set;</span>
[ 2, 3, 4, 5, 7, 8, 9, 11 ]
<span class="GAPprompt">gap></span> <span class="GAPinput"><p>< id"X7DF510F7848CBBFD" name="java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
[ >. <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></div>

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

<h4>21.20 <span class="Heading">Operations for Lists</span></h4>

<Several  java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 263

p id=840 name"X840C55A77D1BB2E1>/>/>

<h5>21.0- Concatenation</h5

<div class="func">table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Concatenation</code>( <var class="Arg">list1</var>, <var class="Arg">list2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
< ">table class="func"=100"<tr>td class=tdleft"<code class="unc>>td class="tdright">( function )</td></tr></table></div>
<p>In the first form <code class="func">Concatenation</code> returns the concatenation of the lists <var class="Arg">list1</var>, <var class="Arg">list2</var>, 

<p>In the second form <var class="Arg">list</var> must be a dense list of lists <var class="Arg">list1</var>, <var class="Arg">list2</var>, etc., and <code class="func">Concatenation</code> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>The result is a new mutable list, that is not identical to any other list. The elements of that list however are identical to the corresponding elements of <var class="Arg">list1</var>, <var class="Arg">list2</var>, etc. (see <a href=

<p>Note that <code classspan<">ap&;span>< "> 123700123 ,1000)/>java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 105


dclass=""<>
<span class="GAPprompt"/pre<div>
[ 1, 2, 3, 4, 5 ]
<span class="GAPprompt<5>21..20-2 Compacted</h5
 ,, ,,7,11, 13,,17, 19 ]
<spanclassjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
[ 1, 2, 3, 2, 3, 4, 3, <>returnsa new mutablelist  containsthe elements of <var class="Arg">list</var> in the same order but omitting the holes.</p>
</pre/

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

<h5>21.20-2 Compacted</h5>

<div class="func"><table class="func" width="100%"><tr><tdjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>returns a new p><a id="X7ECE9056792F28BA="7ECE9056792F28BA><a><p>


dclass"<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<span class="GAPprompt">gap></span> <span class="p>In the second form <class=Arg">ist<var  be a  of lists < class=Arg>ist1<,< =Arg"list2<var> ,and
 1 ,4 [,, 6java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></div>

<>a =X7ECE9056792F28BA =X7ECE9056792F28BA"<a></>

<5>21.20-3 </5java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

< class=""<[  8,[  ][ ,2 ,  7 ]
<p>returns a new list <var class="Arg">new</var> that contains for each element <var class="Arg">elm</var> of the java.lang.StringIndexOutOfBoundsException: Index 118 out of bounds for length 12

<p>For all pairs of elements in <var class="Arg">list</var> the comparison via <code class="code">&


<div class="example"><pre>
<span "GAPprompt>gt;</span <span "GAPinput"Factors((10  )<sjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
 ,2 , ,2 2 ,2,3,,,,5 5,7]
<span class="GAPprompt">gap></span> <span class="GAPinput">Collected( last );
[ , 8 ] [3  ,[ 5 2 ], [ 7,1]java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
<span class="GAPprompt">gap></span> <span class="GAPinput">Collected( last );</span>
[ [ [ 2, 8 ] "java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 26
</pre></div>

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

<h521.-4DuplicateFreeList/>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; DuplicateFreeList</code>( <var class="Arg">list</var> )</td>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; Unique</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table<preturnsthejava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 198
<p>returns a new p< id ="java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 62

<p><code class


<div class="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>
< class"APprompt>&;</pan> < java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 92
[ 1, Z(3), "abc", Group([ (1,2,3), (1,2) ]) ]
</pre></div>

<p><a id="X7F5D4DD87E4378AC" name="<span class="GAPprompt">gap></span> <span=GAPinput"Cartesian 122,[1,java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 81

<h5>21.20-5 AsDuplicateFreeList</h5>

java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 230
<p>returns the same result as <code class="func">DuplicateFreeList</code> (<a href="chap21.html#X8727F2928467C2F9"><<iv class="func"><table<

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

<h5>21.20-6 Flat</h5>

"><java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 215
<p>returns the list of all elements that are contained in the list <var class="Arg">list<p>codeclass="unc>Reversed</ implements aspecial  of list assignment, which can also be formulated 


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

<p>To reconstruct a matrix from the list obtained by applying <code class="func">Flat</code> to the matrix, the<7,6,5,9, 4 1 


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:=[9..14];;w:=2;; # w is the length of each row</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">sub
  9, ,[ , ,[,14  
</pre></div>

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

<h5>21.20-7 Reversed</h5>

<div class="func"><table class="func" width="<panclass="GAPprompt">gap></span> <span class="GAPinput">l := [1..20];</span>
<p>returns a new mutable list, containing the elements of the dense list <var class="Arg">list</var> in reversed order.</p>

<pThe isunchanged.The result  isa  , that is not java.lang.StringIndexOutOfBoundsException: Range [88, 87) out of bounds for length 294

<p><code class="func">Reversed</code> implements a special case of list assignment, java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 71

< class=GAPprompt">gap></span> <span class="GAPinput">Shuffle(l);;</span>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Reversed( [ 1, 4, 9, 5, 6, 7 ] );</span>
[h52120 />
</pre></div>

<p< id"X8057372F83374193=X8057372F83374193"<a>p

<h5>21.20-8 Shuffle</h5>

<div class="func"><table class="func" width="100%"><tr
<p>The argument <var class="Arg">list</var> span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ 1, 2, 3 ];;  Apply( l, i -> i^2 );  l;</span>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Reset(GlobalMersenneTwister, 12345);; # make java.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 0
<class"APprompt">gt<span><panclass="GAPinput> : 1.]<span
[ 1 .. 20 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">m := Shuffle(ShallowCopy(l));</span>
[ 8, 13, 1, 3, 20, 15, 4, 7, 5, 18, 6, 12, 16, 11, 2, 10, 19, 17, 9,
  14 ]
<spanclass="GAPprompt"gap&</ <panclass="GAPinput>l;/span>
[ 1 .. 20 ]
<pan class="GAPprompt">gap></span> <span class="GAPinput">Shuffle(l);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l;</span>
[ 19, 5, 7, 20, 16, 1, 10, 15, 12, 11, 13, 2, 14, 3, 4, 17, 6, 8, 9,
  18 ]
</pre></div>

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

<h5>21.20-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">list</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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 <divclass=example">java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

<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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l:= [ 1, 2, 3 ];;  Apply( l, i -> i^2 );  l;</span>
[ 1, 4, 9 ]
</pre></div>

<><a =X7EF6E2BC81DBF6FB"="7EF6E2BC81DBF6FB">/>/pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>21.20-10 Perform</h5>

<div java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
<>list</var>, discarding  .Itdoes return  value<p>


<iv class=example"<pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [1, 2, 3];; Perform(l,</span>
<span class="GAPprompt">></span> <span class="GAPinput">function(x) if IsPrimeInt(x) then Print(x,"\n"); fi; end);</span>
2
3
</pre></div>

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

<h5>21.20-11 PermListList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PermListList</code>( <var class="Arg">list1</var>, <var class="Arg">list2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns a permutation <span class="SimpleMath">p</span> of <code classjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ 5, 4, 6, 1, 7, 5 ];;</span>
<span class="GAPprompt">gap&

(1,2,4)(3,5,6)
<span class="GAPprompt">gap></span> <span class="GAPinput">Permuted( list2, perm );</span>
[ 5, 4, 6, 1, <>.- <spanclass="Heading">Minimum</span></h5>
</pre></div>

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

<21-12 <="Mspan>/java.lang.StringIndexOutOfBoundsException: Index 54 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; Maximum</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">&#8227; Maximum</code>< class"Arg">list<var></td<td class"tdright"(nbsp;functionnbsp;td</r</table></div>
<p>In the first form <code class="func">Maximum<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<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 list.</p>


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

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

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

h>.20-13 <span class="Heading">Minimum</span></h5>

<div class="func"><table class="func" width="100
<class=f>table " "%>tr<class""<ode f"&8227 Minimumcode>< =Arg>list<var )td< ">&fn)<td<t>/>/>
<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> for which <span class="java.lang.StringIndexOutOfBoundsException: Index 172 out of bounds for length 0

<p>In the second form <code class="func">Minimum</code> takes a homogeneous list <var class="Arg">list</var> and returns the minimum of the elements in this listjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<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 objects <var class="Arg">obj1</var>, <java.lang.StringIndexOutOfBoundsException: Range [0, 241) out of bounds for length 219


<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="X842851EB7E0969F7" name="X842851EB7E0969F7"></a></p>

<52120-14 span java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 74

<div class=div class=example><>
<div class="func"><table class="func" width="100%"><tr><td< class"GAPprompt>&t;/ span class=GAPinput"Cartesian( 1,2][34],[,6]);<spanjava.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 102
p> java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 607

<p>If a second argument <var class="Arg">seed</var> is supplied, then the result is the maximum resp. minimum of the union of <java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 41

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

<h5>21.20-15 <span class="Heading">Cartesian</span></h5>

<divclass=">< class=func "100">tr>td class="tdleft"><code class="func">&#8227; Cartesian</code>( <var class="Arg">list1</var>, <var class="Arg">list2</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<><a id"7F5A782184823" name="X7E76F5A782184823"></a></p>
<p>In the first form <code class="func">Cartesian</code> returns the cartesian product

<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 the first element of <var class="Arg">tup</var> is an tdleft"><code class="func">&#style='color: green'>8227; IteratorOfCartesianProduct</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr<table>/div>

<p>The last index runs fastest. That means that the first element <var class="Arg">tup1</var> of <var class="Arg">cart</var> contains the first element from <var class="Arg">list1</var>, from <var class="Arg">list2</var> and so on. The second element <var class="Arg">tup2</var> of <var class="Arg">cart</var> contains the first element from <var class="Arg">list1</var>, the first from <var class="Arg">list2</var>, and so on, but the last element of <var class="Arg">tup2</var<Inthe firstform code "">/ode>(see < href=chap30html#X85A3F00985453F95>spanclass="RefLink">30.8</span></a>) of all elements of the cartesian product (see <code class="func">Cartesian</code> (<a href="chap21.html#X7E1593B979BDF2CD"><span class="RefLink">21.20-15</span></a>)) of the lists <var class="Arg">list1</var>, <var class="Arg">list2</var>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>The function <code class="func">Tuples</code> (<a href="chap16.html#X86A3CA0F7CC8C320"><span class="RefLink">16.2-8</span></a>) computes the <var class="Arg">k</var>-fold cartesian product of a list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Cartesian( [1,2], [3,4], [5,6] );<iv class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#tyle='color: green'>8227; Permuted</code>( <var class="Arg">list</var>, <var class="Arg">perm</var> )</td><td class="tdright">( operation )</td></tr></table></div>
[[1,3,5], 1,3,6 ], [1,4, 5 ][ 1,4 6,[2 3, 5 ,
  [ 2, 3, 6 ], [ 2, 4, 5 ], [ 2, 4, 6 ] ]
spanclass=GAPprompt"gap>span spanclass="GAPinput">Cartesian( [1,2,2], [1,1,2] );</span>
[ [ 1, 1 ], [ 1, 1 ], [ 1, 2 ], [ 2, 1 ]
  [ 2, 1 ], [ 2, 1 ], [ 2, 2 ] ]
<p>/divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

<"X7E76F5A782184823"name="X7E76F5A782184823">a>/>

<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</code>( <var class="Arg<>id="86"nameX86CB7DCE8510F977>/<p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IteratorOfCartesianProduct</code><h5>1.20-8 List</h5>
<p>In the first form <code class="func">IteratorOfCartesianProduct</code> returns an iterator (see <a href="chap30.html#X85A3F00985453F95"><span class=">This function returns a new mutable list <code class="code">new</code> of the same length as the list <var class="Arg">list</var> (which may have holes). Theunbound  if <code ="code"<var class=A"list</var[i</ode is unbound.Otherwise <ode ="code"new[]  < ="func<var(<arclass="Arg"list</>i]/code> Ifthe  <class"Arg">func<v> is omitted, its default is <code class="func">IdFunc</code> (<a href="chap5.html#X810325697BDEF899"><span class="RefLink">5.4-6</span></a>), so this function does the same as <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) (

<p>In <var=>< be  java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 261

<p>Resulting tuples will be span class="GAPprompt">gap></span> <span class="GAPinput">List( [1..10], IsPrime );</span>

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

<5>21.20-17 h5

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code 
<p>returns a new list h>19 java.lang.StringIndexOutOfBoundsException: Range [25, 21) out of bounds for length 26

<p><code class="func">Sortex</code> (<a href="chap21.html#X87287FCA81E2B06A"><span class="RefLink">21.18-3</span></a>) allows you to compute a permutation that must be applied to a list in order topra 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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Permuted( [ 5, 4, 6, 1, 7, 5 ], (1<>each elementof var class=Arg>/>,< class=Arg"><>  java.lang.StringIndexOutOfBoundsException: Range [105, 104) out of bounds for length 208
[ p resulta isjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 256
<span class="GAPprompt">gap></span> <span class="GAPinput">Permuted
[,,,5 6  ]
</pre></div>

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

<h5>21.20-18 List</h5>

<div class=func"<table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#n 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>
<>This function returns a new mutable list <code class="code">new</code> of the same length as the list <var class="Arg">list</var> (which may have holes). The entry <code class="code">new[i]</code> is unbound if <code class="code"><var class="Arg">list</var>[i]</code> is unbound. Otherwise <code class="code">new[i] = <var class="Arg">func</var>(<var class="Arg">list</var>[i])</code>. If the span =GAPprompt>gt;/pan> span =GAPinput"( 1 ,4,44 7,106  IsPrimePowerInt);/span>

<tom list or collection types need toinstall suitable methods for the operation <code class="code">ListOp</code>.</p>


dclass=example"<
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [1,2,3], i -> i^2 );</span>
[ 1, 4, 9 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [1..10], IsPrime );</span>
[ 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>

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

<h5>21.20-19 Filtered</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Filtered</code>( <var class="Arg">listorcoll</var>, <var class="Arg">func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>java.lang.StringIndexOutOfBoundsException: Range [206, 10) 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="keyw">true</code> appears several times in the list it will also appear the same number of times in the result. The argument list may contain holes, they are ignored by <code class="func">Filtered</code>.</p>

 <code class="keyw>/ <code =keyw"false<> otherwise an error is ./>

<p>The result is a new list that is 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>

<> assignment using the operator <code class="func">\{\}</code> (<a href="chap21.html#X78791B8B838A8BA0"><span class="RefLink">21.3-1</span></a>) (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>) can be used to extract elements of a list according to indices given in another list.</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">FilteredOp</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Filtered( [1..20], IsPrime );</span>
[ 2, 3, 5, 7, 11spanclass=">&;/span> <java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 94
<span class="GAPprompt">gap></span> <span class="GAPinput">Filtered( [ 1, 3, 4, -4, 4, 7, 10, 6 ], IsPrimePowerInt span class=GAPprompt">gap&t;<span ">umber([, ,3,, 5, ,,11  )</span>
[ 3, 4, 4, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Filtered( [ 1, 3, 4, -4, 4, 7, 10, 6 ],</span>
<span class="GAPprompt">></span> <span class="GAPinput<pan java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 125
[ 3, 7 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Filtered( Group( (1,2), (1,2,3) ), x -> Order( x ) = 2 );</span>
[(2,),1,2)1, ]
</pre></div>

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

<h5>21.20-20 Number</h5>

<class"unc"<class=func"width="00">tr< =tdleft>code class="&#8227; Number</code>( <ar "">listorcoll<var>,< class="Arg><>] )</td><td ="tdright">&bsp;njava.lang.StringIndexOutOfBoundsException: Range [228, 227) out of bounds for length 253
<p>Called with a list <var class="Arg

<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="funcof <var class="Arg">listorcoll</var> (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>).</p>

<p>For each element of <var class="Arg">listorcoll</var>, <var class="Arg">func</var> must return either <code class="keyw">true</code> or <code class="keyw">false</code>, otherwise an error is signalled.<span class="GAPprompt">gap></span> <span class="GAPinput">Number( [1..20], IsPrime );</span>

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

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


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( [ 2, 3, 5, 7 ] );</span>
4
<java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 104
5
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( [1..20], IsPrime );</span>
8
<
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 ->
2
<span class="GAPprompt">gap></span> <span class="GAPinput">Number( java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 0
3
<d>

<p><a id="X82801DFA84E11272" name="X82801DFA84E11272<pan =GAPprompt"gap>/pan><pan class=GAPinput"Product( 8 ;<spanjava.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86

<h5>21.20/pre>div>

<div class="func"><table class="func" width="100span class"GAPprompt"gapgt<span <panclassp><a id="X7A04B71C84CFCC2D" name="X7A04B71C84CFCC2D">java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
code java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 715

<p>

<p<<code =">/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 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


< "GAPprompt>><span <pan=G"     n -gt notIsPrime(n)andIsPrimePowerInt(n) );</span>
<span classpIf java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 440
10000019
<span class=
<"GAPprompt">/span><pan =GAPinput"     n > not IsPrime()and IsPrimePowerInt(n) );</span>
100489
spanclass=GAPprompt>gt;<span>s =GAPinput"First  1 .20 ], &  &t;0)<span>
il
<p java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 163
fail
<pre>/div>

E9">a<>

<h5>21.20-22 Last</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code classp>a id"X834E4DF57F3A20F0=X834">/><>
<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 classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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


<div class=<p>returns the result of the iterated application of the function <var class="Arg">f</var>, which must take two arguments, to the elements of the list <var class="Arg">list</var>. More precisely, if <var class="Arg">list</var> has length <span class="SimpleMath">n</span> then <code class="func">Iterated</code> returns the result of the following 
<span class="GAPprompt">gap></span> <span class="GAPinput">Last( [10^7..10^8], IsPrime );</span>
99999989
<span class="GAPprompt3
<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
fail
</pre></div>

<p><a id="X7F06961278166671" name="X7F06961278166671"></a></pjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

h2120- 

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ForAll</code>( <var class="Arg">listorcoll</var>, <var class="Arg">func</var> )</td><java.lang.StringIndexOutOfBoundsException: Index 188 out of bounds for length 12
<ptests   unaryfunction<ar class=""func<var>returns< class=keyw">rue<code> allelementsin thelist or collection<class=Arg"></ar.<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">ForAllOp</code>.</h4>21.21 <span class="Heading">Advanced List Manipulations</span></h4>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll( [1..20], IsPrime );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll( [2><class=>#8227 Product</code>( <var class="Arg">listorcoll</var>[, <var class="Arg">func</var>][, <var class="Arg">init</var>] )</td><td class="tdright">( function )</td></tr></table></div>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll( [2..14], n -> IsPrimePowerInt(n) or n mod 2 = 0 );</span>
true
<p> with argument, dense or  vclass=Arg"listorcoll<var> <ode ">/ the of elements  <var "Arg"listorcoll<var>(ee a "html#"span "efLink"30<span>/>./>
false
</pre></div>

<BDA75"></a<p>

<h5>21.20-24 ForAny</h5>

<div class="func"><table class="func" width=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>tests whether the unary function <var class="Arg">func</var> returns <code class="keyw">true</code> for at least one element in the list or collection <var class="Arg">listorcoll</var>.</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">ForAnyOp</code>.</p>


<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
<panclass="GAPprompt">gap></span> <span class="GAPinput">ForAny( [2..14],</span>
rimePowerInt() andn mod   0 and notIsPrime(n<p>ests whether<var  class"Arg"obj/>is represented a range, that internallystoring onlythe first value the in or decrement, and  last value  range.</p>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAny( Integers, i ->     i > 0</span class="GAPprompt">gap></span> <span class="GAPinput">Product( [ (1,2), (1,3), (1,4), (2,3), (2,4), (3,4) ] );</span>
<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%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Product</
<>Calledwith one argument, a dense list or collection <var class="Arg">listorcoll</var>, <code class="func">Product</code> returns the product of the elements of <var class="Arg">listorcoll</var> (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>).</p>

<p>Called p>   domains can be implemented via <div  class=example>pre>

<p>The general rules for arithmetic operations apply (see <a href="chap21.html#X8676EFE67972FD06"><span class="RefLink">21.15</span></a>), so the result is immutable if and only if all summands are immutable.</p>

<p> <ar 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 h5>21.23-1 IsQuickPositionList>

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


<div class="example"><pre>
<an =APprompt">gap></span> <span class="GAPinput">Product( [ 2, 3, 5, 7, 11, 13, 17, 19 ] );</span>
9699690
<span class="GAPprompt">gap></span> <span class="
13168189440000
<span class="GAPprompt">gap></span> <span class="GAPinput">Product( [ (1,2), (1,3), (1,4), (2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(1,4)(2,3)
<span class="GAPprompt">gap></span> <span class="GAPinput">Product( GFp><id="X8438CB908367254C" name=X8438CB908367254C"></a></p>
0<panclass="GAPprompt>>/pan>span =GAPinput"ListN 12] <2124-<5
</pre></div>

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

<h5>21.20-26 Sum</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Sum<
<p>Called with one argument, a dense list or collection <var class="Arg">listorcoll</var>, <code class="func">Sum</code> returns the sum of the elements of <var class="Arg">listorcoll</var> (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>).</p>

<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 function taking java.lang.StringIndexOutOfBoundsException: Index 155 out of bounds for length 0

<pThegeneral rules for operations see <href="chap21.html#X8676EFE67972FD06"><span class="RefLink">21.15</span></a>), so the result is immutable if and only if all summands are immutable.</p>

<p>If <var class="Arg">listorcoll</var> contains exactly oned "func><able ="width"%><r>< java.lang.StringIndexOutOfBoundsException: Range [330, 65) out of bounds for length 330

<p>If an additionalinitial value <var class="Arg">init</var> is given, <code class="func">Sum</code> returns the sum 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 zero than <code class="code">0</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">SumOp</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Sum( [ 2, 3, 5, 7, 11, 13, 17, 19 ] );</span>
77
<span class="GAPprompt">java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 125
385
<class=GAPprompt">gap></span> <span class="GAPinput">Sum( [ [1,2], [3,4], [5,6] ] );</span>
[ 9, 12 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Sum( GF(8) );</span>
0*Z(2)
</pre></div>

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

<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> )</td><td class="tdright">( operation )<
<returnsthe result theiterated ofthe java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 617


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Iterated( [ 126, 66, 105 ], Gcd );</span>
3
</pre></div>

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

<h5>21.20-28 ListN</h5>

<class=func""%"<tr><td ="java.lang.StringIndexOutOfBoundsException: Range [74, 72) out of bounds for length 330
<p>applies the <span class="SimpleMath">n</span>-argument function <var class="Arg">f</var> to the lists. That is, <code class="func">ListN</code> returns the list whose <span class="SimpleMath">i</span>-th entry is <span class="SimpleMath"java.lang.StringIndexOutOfBoundsException: Index 240 out of bounds for length 38


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

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

<h4>21.21 <span class="Heading">Advanced List Manipulations</span></h4>

<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> (java.lang.StringIndexOutOfBoundsException: Index 195 out of bounds for length 12

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

<h5>21.21-1 ListX</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code<iv class=""<>
<p><code class="func">ListX</code> returns a new list constructed from the argumentss =java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 96

<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>
<dth5>.- /java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
<>p> a new for-loop in the sequence of nested for-loops and if-statements;</p>

</dd</>he 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>
<dt><strong class="Mark">a function returning a list or collection</strong></dt>
<>p>java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 171

</dd>
<dt><strong class
<dd><p>this introduces a new if-statement in the sequence of nested for-loops and if-statements.</p>

</dd>
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 5
<>helast 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 java.lang.StringIndexOutOfBoundsException: Index 396 out of bounds for length 0

<p>As a more elaborate example, assume <var class="Arg">arg1</var> is a list or collection, <var class="Arg">arg2</var> is

<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><p><c "unc"><code>returnsthe of  inthe listobtainedby c class">istX</code> (<a href="chap21.html#X8258477D7F72171B"><span class="RefLink">21.21-1</span></a>) whenthis calledwiththe same ./


<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;
;
</pre></div>

<p>The following example shows how <code class="func">ListX</code> can be used to <p><code class="code">[ <var class="Arg">first</var> .. <var class="Arg">last</var> ]</co


<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, ]  4,3 ,[4,4  java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
</pre></div>

<p>In the following example, <code class="func">\<<iv"><pre


<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"java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

<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; SetXjava.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 82
<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</java.lang.StringIndexOutOfBoundsException: Index 235 out of bounds for length 5

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

<h5>21.21-3 SumX</h5>

<[ 1, 3 .. 17 ]
<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>

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

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><<class=">g;/>s"java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 74
<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 <span class"GAPprompt"gapgt<span><span class="GAPinput">r := [ 1, 4 .. 32 ];</span>

<>< java.lang.StringIndexOutOfBoundsException: Range [182, 181) out of bounds for length 195

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

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

<p>If <code class="code"><var

<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 );<java.lang.StringIndexOutOfBoundsException: Index 168 out of bounds for length 168
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] );  IsRange( [7,5,3,1] );</span>
true
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange( [1 .. 3] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRange( [1,2,4,5] );  IsRange( [1,,3,,5,,7] );</span>
false

<span class="GAPprompt">gap></span> <span class="<div class="func"><table class="func" width="100%"><tr><td ccode class=f"&8227;/ode( =Arg"o<var <td< class=>&category )/>/tr>/<div>
true
true
</pre></div>

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

<h5>21.22-2 IsRangeRep</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsRangeRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">( representation )</td></tr></table></div>
<p>Tests whether <var class="Arg">obj</var> is represented as a range, that is by internally storing only the first value, the in- or decrement, and the last value of the range.</p>

<p>To test whether a list is a range in the mathematical sense see <code class="func">IsRange</code> (<a href="chap21.html#X86DDC2FF7A50FBEE"><span class="RefLink">21.22-1</span></a>).</p>

< bythe 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>

<p>Note that if you modify an <code class="func">IsRangeRep</code> object by assigning to one of its


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class=GAPinput>sRangeRep  .3 ;/java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRangeRep( [1, 2[ 1, 2 4, 5]
false
< class="APprompt">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>
[1, , 3 ]
</pre></div>

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

<>n <m>java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 466

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ConvertToRangeRep</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For some lists the <strong class="pkg">GAP</strong> kernel knows that they are in fact ranges. Those lists are represented internally in a compact way, namely in <code class="func">IsRangeRep</code> (<a href

<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">


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">r:= [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];</span>
[ 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> is an immutable list that need not 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 than a binary search in a sorted list of vectors, see <code class="func">IsQuickPositionList</code> (<a href="chap21.html#X7BB462C17962647F"><span class="RefLink">21.23-1</span></a>).</p>

<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 elements. On the other hand, an enumerator may save a vast amount of memory. Take for example a permutation group of size a few millions. Even for moderate degree it is unlikely that a list of all its elements will fit into memory whereas it is no problem to construct an enumerator fromjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>There are situations where one only wants to loop over thep>This indicatesthat  test  var class="rg"list<var> is quicker than about 5or  comparisonsfor q><q.If is the it can bebeneficialto  code "><code> (<a href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>) in <var class="Arg">list</var> and a bit list than ordered lists to represent subsets of <var class="Arg">list</var>.</p>

<p>The functions <code class="func">Enumerator</code> (<a href="chap30.html#X7EF8910F82B45EC7"><span class="RefLink">30.3java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p>Also enumerators for non-domains can be implemented via <code class="func">EnumeratorByFunctions</code> (<a href="chap30.html#X85E149177AC547C3"><span class="RefLink">30.3-4</span></a>); for a discussion, see <a href="chap79.html#X849D8BC278649EA5"><span class="RefLink">79.5</span></a>.</p>

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

<h5>21.23-1 IsQuickPositionList</h5

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsQuickPositionList</code>( <var class="Arg">java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
pThis 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 href="chap21.html#X79975EC6783B4293"><span class="RefLink">21.16-1</span></a>) in <var class="Arg">list</var> anda bit list than  lists   subsets  <ar class"">ist<var><pjava.lang.StringIndexOutOfBoundsException: Index 433 out of bounds for length 433

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

<h4>21.24 <span class="Heading">Plain Lists</span></h4>

<p>Plain lists are the default kind of lists in <strong class="pkg">GAP</strong>, in the sense that <strong class="pkg">GAP</strong> stores the list entries and does not know how to do better (as opposed to ranges or strings, which are also lists). Often it is not necessary to know how a given list is represented internally, the operations defined for lists apply to all lists.</p>

<p>Typical situations where 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>

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

<h5>21.24-1 PlainListCopy</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PlainListCopy</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns a list equal to its argument, in a plain list representation (see <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)). This is intended for use in certain rare situations, such as before objectifying, or calling some kernel functions.</p>

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

<h5>21.24-2 IsPlistRep</h5>

<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">( representation )</td></tr></table></div>
<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">IsBlistRep</code> (<a href="chap22.html#X8453ADDA810B4C03"><span class="RefLink">22.5-1</span></a>), <code class="func">IsRangeRep</code> (<a href="chap21.html#X83896BC481536B07"><span class="RefLink">21.22-2</span></a>), <code class="func">IsStringRep</code> (<a href="chap27.html#X7A17EDF8785C9F58"><span class="RefLink">27.4-1</span></a>), or the ones that are chosen for implementing enumerators, see Section <a href="chap21.html#X7EA3ACE27E43D174"><span class="RefLink">21.23</span></a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlistRep( [ 1, 2, 3 ] );</span>
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"<p>This function returns a list equal to its argument, in a plain list representation (see <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)). This is intended for use in certain rare situations, such as before objectifying, or calling some kernel functions.</p>

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

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

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.300Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1128594
#Domains=1976912