|
|
|
|
Quelle chap21.html
Sprache: HTML
|
|
| products/Sources/formale Sprachen/GAP/doc/ref/chap21.html |
 |
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "en">
< head>
< title>GAP (ref) - Chapter 21: Lists</ title>
< meta http-equiv= "content-type" content= "text/html; charset=UTF-8" />
< meta name= "generator" content= "GAPDoc2HTML" />
< link rel= "stylesheet" type= "text/css" href= "manual.css" />
< script src= "manual.js" type= "text/javascript"></ script>
< script type= "text/javascript">overwriteStyle();</ script>
</ head>
< body class= "chap21" onload= "jscontent()">
< div class= "chlinktop">< span class= "chlink1">Goto Chapter: </ span>< a href= "chap0.html">Top</ a> < a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chap6.html">6</a> <a href="chap7.html">7</a> <a href="chap8.html">8</a> <a href="chap9.html">9</a> <a href="chap10.html">10</a> <a href="chap11.html">11</a> <a href="chap12.html">12</a> <a href="chap13.html">13</a> <a href="chap14.html">14</a> <a href="chap15.html">15</a> <a href="chap16.html">16</a> <a href="chap17.html">17</a> <a href="chap18.html">18</a> <a href="chap19.html">19</a> <a href="chap20.html">20</a> <a href="chap21.html">21</a> <a href="chap22.html">22</a> <a href="chap23.html">23</a> <a href="chap24.html">24</a> <a href="chap25.html">25</a> <a href="chap26.html">26</a> <a href="chap27.html">27</a> <a href="chap28.html">28</a> <a href="chap29.html">29</a> <a href="chap30.html">30</a> <a href="chap31.html">31</a> <a href="chap32.html">32</a> <a href="chap33.html">33</a> <a href="chap34.html">34</a> <a href="chap35.html">35</a> <a href="chap36.html">36</a> <a href="chap37.html">37</a> <a href="chap38.html">38</a> <a href="chap39.html">39</a> <a href="chap40.html">40</a> <a href="chap41.html">41</a> <a href="chap42.html">42</a> <a href="chap43.html">43</a> <a href="chap44.html">44</a> <a href="chap45.html">45</a> <a href="chap46.html">46</a> <a href="chap47.html">47</a> <a href="chap48.html">48<<xml="0encoding=UTF-?>
<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a> <a href="chap0.html#contents">[Contents]</a> <a href="chap20.html">[Previous Chapter]</a> <a href="chap22.html">[Next Chapter]</a> </div>
<p id="mathjaxlink" class="pcenter"><a href="chap21_mj.html">[MathJax on]</a></p>
<p><a id="X7B256AE5780F140A" name="X7B256AE5780F140A"></a></p>
<div class="ChapSects"><a href="chap21.html#X7B256AE5780F140A">21 <span class="Heading">Lists</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X86B28F5B781FFD31">21.1 <span class="Heading">List Categories</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C4CC4EA8299701E">21.1-1 IsList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X870AA9D8798C93DD">21.1-2 IsDenseList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X80872FAF80EB5DF9">21.1-4 IsTable</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79581E0387F7F7A9">21.1-5 IsRectangularTable</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C84E16A85C99C8C">21.1-6 IsConstantTimeAccessList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7B202D147A5C2884">21.2 <span class="Heading">Basic Operations for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8297BBCD79642BE6"><code>21.2-1 <span>\</span>[<span>\</span>]</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7921047F83F5FA28">21.3 <span class="Heading">List Elements</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X78791B8B838A8BA0"><code>21.3-1 \{\}</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8611EF768210625B">21.4 <span class="Heading">List Assignment</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X813FF1637F8D2B7F"><code>21.4-1 \{\}\:\=</code></a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X795EC9D67E34DAB0">21.4-2 Add</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E98B11B79BA9167">21.4-3 Remove</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79D7E96F80A2D7C0">21.4-4 CopyListEntries</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79E31DB27C82D6E1">21.4-5 Append</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7963C8E17EFF86DB">21.5 <span class="Heading">IsBound and Unbind for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79EC565A7DCEC938">21.5-1 IsBound</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X866F45D3797FDA00">21.5-2 GetWithDefault</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X78B72FDF7BD63C0B">21.5-3 Unbind</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7DD65BEA7EDB0CD7">21.6 <span class="Heading">Identical Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7ED7C0738495556F">21.7 <span class="Heading">Duplication of Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X808A207182B2F84F">21.8 <span class="Heading">Membership Test for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B914A287F88ED0A"><code>21.8-1 \in</code></a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X84D6FC7E7E39ED33">21.9 <span class="Heading">Enlarging Internally Represented Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X78BF67A5802E93AD">21.9-1 EmptyPlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8016D50F85147A77">21.10 <span class="Heading">Comparisons of Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X845EEAF083D43CCE">21.11 <span class="Heading">Arithmetic for Lists</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X84D642967B8546B7">21.12 <span class="Heading">Filters Controlling the Arithmetic Behaviour of Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X87ABCEE9809585A0">21.12-1 IsGeneralizedRowVector</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FBCA5B58308C158">21.12-2 IsMultiplicativeGeneralizedRowVector</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7BAD12E67BFC90DE">21.12-3 IsListDefault</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8428E77B86722D52">21.12-4 NestingDepthA</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X84B383B97FD986CD">21.12-5 NestingDepthM</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7E6A1F66781BE923">21.13 <span class="Heading">Additive Arithmetic for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X86A85ADC85C451DC">21.13-1 <span class="Heading">Zero for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B91CE4D814C2D08">21.13-2 <span class="Heading">AdditiveInverse for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X842D123E7EE5E3DB">21.13-3 <span class="Heading">Addition of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C3DC8BE78DEECDE">21.13-4 <span class="Heading">Subtraction of lists</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X782ED7F27D8C7FC1">21.14 <span class="Heading">Multiplicative Arithmetic for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79A8A5627FD42FA5">21.14-1 <span class="Heading">One for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X78C6C1E2849D303A">21.14-2 <span class="Heading">Inverse for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X84FDB95179BFE4CD">21.14-3 <span class="Heading">Multiplication of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X82EA2A5B786181C7">21.14-4 <span class="Heading">Division of lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7A0FD70C80B95C00">21.14-5 <span class="Heading">mod for lists</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X84BB2DFB8432A1A4">21.14-6 <span class="Heading">Left quotients of lists</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8676EFE67972FD06">21.15 <span class="Heading">Mutability Status and List Arithmetic</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X80FDB1457FF582E7">21.15-1 ListWithIdenticalEntries</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X8196FD4779BCCA0C">21.16 <span class="Heading">Finding Positions in Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79975EC6783B4293">21.16-1 Position</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FA9648883AE1B88">21.16-2 Positions</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B4B10AE81602D4E">21.16-3 PositionCanonical</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7D2B25B484591506">21.16-4 PositionNthOccurrence</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7A122E848464E534">21.16-5 PositionSorted</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X820BA44D85930EBF">21.16-6 PositionSortedBy</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X78BFE9D78347C0DA">21.16-7 PositionSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FD9C1D37F300206">21.16-8 PositionMaximum</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E6C763A82C6153B">21.16-9 PositionProperty</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7DA94D278304EC3D">21.16-10 PositionsProperty</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X86C9E5C3863B3C03">21.16-11 PositionBound</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X819F71047AABEA2F">21.16-12 PositionsBound</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X865EF45D87ED1384">21.16-13 PositionNot</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7F42E5AD87EC9D5A">21.16-14 PositionNonZero</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X87A8C62A867D6DA4">21.16-15 PositionSublist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7865747A7CCF5812">21.17 <span class="Heading">Properties and Attributes for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X83F8EC7C7BF27EFC">21.17-1 IsMatchingSublist</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FA892828252BB3B">21.17-2 IsDuplicateFree</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7BAA9B0E81D4A884">21.17-3 IsSortedList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X80CDAF45782E8DCB">21.17-4 IsSSortedList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X780769238600AFD1">21.17-5 Length</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B55FB967CDEF468">21.17-6 ConstantTimeAccessList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X83E558E37D1B44D4">21.18 <span class="Heading">Sorting Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FE4975F8166884D">21.18-1 Sort</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X791F2B2C7E9B9A46">21.18-2 SortParallel</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X87287FCA81E2B06A">21.18-3 Sortex</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X800209E881E7CECB">21.18-4 SortingPerm</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X80ABC25582343910">21.19 <span class="Heading">Sorted Lists and Sets</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B16AD597CB12305"><code>21.19-1 \in</code></a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B4C0FEE7CDF6F2A">21.19-2 IsEqualSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X79B940567A849216">21.19-3 IsSubsetSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X832C23CC7FCD8892">21.19-4 AddSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FCA282E789A4F4B">21.19-5 RemoveSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B3469CD7EFC1A87">21.19-6 UniteSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8473AA657FEC3D4D">21.19-7 IntersectSet</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X80B427537EB07D09">21.19-8 SubtractSet</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7DF510F7848CBBFD">21.20 <span class="Heading">Operations for Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X840C55A77D1BB2E1">21.20-1 Concatenation</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7CB0A6AF87C7FAF7">21.20-2 Compacted</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7ECE9056792F28BA">21.20-3 Collected</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8727F2928467C2F9">21.20-4 DuplicateFreeList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7F5D4DD87E4378AC">21.20-5 AsDuplicateFreeList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FA272D984EF82ED">21.20-6 Flat</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C4FDB007C3F54A1">21.20-7 Reversed</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8057372F83374193">21.20-8 Shuffle</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8075FBDE7B81B4C8">21.20-9 Apply</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7EF6E2BC81DBF6FB">21.20-10 Perform</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8763882A7D65F979">21.20-11 PermListList</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X82CE0DE8828E4303">21.20-12 <span class="Heading">Maximum</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X82F133EC7F89665F">21.20-13 <span class="Heading">Minimum</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X842851EB7E0969F7">21.20-14 <span class="Heading">MaximumList and MinimumList</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E1593B979BDF2CD">21.20-15 <span class="Heading">Cartesian</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E76F5A782184823">21.20-16 <span class="Heading">IteratorOfCartesianProduct</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7B5A19098406347A">21.20-17 Permuted</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X86CB7DCE8510F977">21.20-18 List</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7C86D7F7795125F0">21.20-19 Filtered</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8179B13D80E935FC">21.20-20 Number</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X82801DFA84E11272">21.20-21 First</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E5B62E780421CE9">21.20-22 Last</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7F06961278166671">21.20-23 ForAll</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7AF82E747A8BDA75">21.20-24 ForAny</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7E5C72F27B657948">21.20-25 Product</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7A04B71C84CFCC2D">21.20-26 Sum</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X834E4DF57F3A20F0">21.20-27 Iterated</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7D150C2881881139">21.20-28 ListN</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X805CA0B68029B47A">21.21 <span class="Heading">Advanced List Manipulations</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8258477D7F72171B">21.21-1 ListX</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7AC321B87A2DCAF5">21.21-2 SetX</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X82B1411E7FBE925F">21.21-3 SumX</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FB318B47D8783DA">21.21-4 ProductX</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X79596BDE7CAF8491">21.22 <span class="Heading">Ranges</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X86DDC2FF7A50FBEE">21.22-1 IsRange</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X83896BC481536B07">21.22-2 IsRangeRep</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7D22B2298167A58F">21.22-3 ConvertToRangeRep</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X7EA3ACE27E43D174">21.23 <span class="Heading">Enumerators</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7BB462C17962647F">21.23-1 IsQuickPositionList</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap21.html#X81ECC2077D88E112">21.24 <span class="Heading">Plain Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X8438CB908367254C">21.24-1 PlainListCopy</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X87BA4EBF80F16B72">21.24-2 IsPlistRep</a></span>
</div></div>
</div>
<h3>21 <span class="Heading">Lists</span></h3>
<p>Lists are the most important way to treat objects together. A <em>list</em> arranges objects in a definite order. So each list implies a partial mapping from the integers to the elements of the list. I.e., there is a first element of a list, a second, a third, and so on. Lists can occur in mutable or immutable form, see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a> for the concept of mutability, and <a href="chap21.html#X7ED7C0738495556F"><span class="RefLink">21.7</span></a> for the case of lists.</p>
<p>This chapter deals mainly with the aspect of lists in <strong class="pkg">GAP</strong> as <em>data structures</em>. Chapter <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a> tells more about the <em>collection</em> aspect of certain lists, and more about lists as <em>arithmetic objects</em> can be found in the chapters <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>.</p>
<p>Lists are used to implement ranges (see <a href="chap21.html#X79596BDE7CAF8491"><span class="RefLink">21.22</span></a>), sets (see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>), strings (see <a href="chap27.html#X7D28329B7EDB8F47"><span class="RefLink">27</span></a>), row vectors and matrices (see <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>, but note that <strong class="pkg">GAP</strong> supports also linear algebra for objects which are <em>not</em> lists, see <a href="chap26.html#X856C23B87E50F118"><span class="RefLink">26</span></a>); boolean lists (see <a href="chap22.html#X7AC531DD79B6938E"><span class="RefLink">22</span></a>) are a further special kind of lists.</p>
<p>Several operations for lists, such as <code class="func">Intersection</code> (<a href="chap30.html#X851069107CACF98E"><span class="RefLink">30.5-2</span></a>) and <code class="func">Random</code> (<a href="chap30.html#X7FF906E57D6936F8"><span class="RefLink">30.7-1</span></a>), will be described in Chapter <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>, in particular see <a href="chap30.html#X7C3722DF8736FFDB"><span class="RefLink">30.3</span></a>.</p>
<p><a id="X86B28F5B781FFD31" name="X86B28F5B781FFD31"></a></p>
<h4>21.1 <span class="Heading">List Categories</span></h4>
<p>A list can be written by writing down the elements in order between square brackets <code class="code">[</code>, <code class="code">]</code>, and separating them with commas <code class="code">,</code>. An <em>empty list</em>, i.e., a list with no elements, is written as <code class="code">[]</code>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ]; # a list with three elements</span>
[ 1, 2, 3 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ [], [ 1 ], [ 1, 2 ] ]; # a list may contain other lists</span>
[ [ ], [ 1 ], [ 1, 2 ] ]
</pre></div>
<p>Each list constructed this way is mutable (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>).</p>
<p><a id="X7C4CC4EA8299701E" name="X7C4CC4EA8299701E"></a></p>
<h5>21.1-1 IsList</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">an style='color: green'>8227; IsList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>tests whether <var class="Arg">obj</var> is a list.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsList( [ 1, 3, 5, 7 ] ); IsList( 1 );</span>
true
false
</pre></div>
<p><a id="X870AA9D8798C93DD" name="X870AA9D8798C93DD"></a></p>
<h5>21.1-2 IsDenseList</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">an style='color: green'>8227; IsDenseList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A list is <em>dense</em> if it has no holes, i.e., contains an element at every position up to the length. It is absolutely legal to have lists with holes. They are created by leaving the entry between the commas empty. Holes at the end of a list are ignored. Lists with holes are sometimes convenient when the list represents a mapping from a finite, but not consecutive, subset of the positive integers.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsDenseList( [ 1, 2, 3 ] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ , 4, 9,, 25,, 49,,,, 121 ];; IsDenseList( l );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">l[3];</span>
9
<span class="GAPprompt">gap></span> <span class="GAPinput">l[4];</span>
List Element: <list>[4] must have an assigned value
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' after assigning a value to continue
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">l[4] := 16;; # assigning a value</span>
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">return; # to escape the break-loop</span>
16
gap>
</pre></div>
<p>Observe that requesting the value of <code class="code">l[4]</code>, which was not assigned, caused the entry of a <code class="keyw">break</code>-loop (see Section <a href="chap6.html#X8593B49F8705B486"><span class="RefLink">6.4</span></a>). After assigning a value and typing <code class="code">return;</code>, <strong class="pkg">GAP</strong> is finally able to comply with our request (by responding with <code class="code">16</code>).</p>
<p><a id="X7C71596C82B6EF35" name="X7C71596C82B6EF35"></a></p>
<h5>21.1-3 IsHomogeneousList</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">an style='color: green'>8227; IsHomogeneousList</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if <var class="Arg">obj</var> is a list and it is homogeneous, and <code class="keyw">false</code> otherwise.</p>
<p>A <em>homogeneous</em> list is a dense list whose elements lie in the same family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>). The empty list is homogeneous but not a collection (see <a href="chap30.html#X8050A8037984E5B6"><span class="RefLink">30</span></a>), a nonempty homogeneous list is also a collection.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHomogeneousList( [ 1, 2, 3 ] ); IsHomogeneousList( [] );</span>
true
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHomogeneousList( [ 1, false, () ] );</span>
false
</pre></div>
<p><a id="X80872FAF80EB5DF9" name="X80872FAF80EB5DF9"></a></p>
<h5>21.1-4 IsTable</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">an style='color: green'>8227; IsTable</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A <em>table</em> is a nonempty list of homogeneous lists which lie in the same family. Typical examples of tables are matrices (see <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsTable( [ [ 1, 2 ], [ 3, 4 ] ] ); # in fact a matrix</span>
true
< class=GAPprompt"gap&/pan> <span =GAPinput"IsTable([ 1 ] 2, 3 ]); #rectangularbut java.lang.StringIndexOutOfBoundsException: Range [130, 129) out of bounds for length 136
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsTable<
false
</pre></div>
<p><a id="X79581E0387F7F7A9" name="X79581E0387F7F7A9"></a></p>
<h5>21.1-5 IsRectangularTable</h5>
<; IsRectangularTable</code>(java.lang.StringIndexOutOfBoundsException: Index 228 out of bounds for length 228
<p>A list lies in <code class="code">IsRectangularTable</codeclass=""< />span class="">&bsp;nbsp;/span>a =chap21.tml#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>
<pspan ""<br/< =nocss>;nbsp;/<ahref".htmlX7C84E16A85C99C8C"java.lang.StringIndexOutOfBoundsException: Range [139, 137) out of bounds for length 148
<h5>21.1-6 IsConstantTimeAccessList</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 7
<p>This category indicates whether the access to each element of the list <var class="Arg">list</var> will take roughly the same time. This is implied for example by <code class="code">IsList and IsInternalRep</code>, so all strings, Boolean lists, ranges, and internally represented plain lists are in this category.</p>
<p>div class="ContSSBlock">
<a =X7B202D147A5C2884=X7B202D147A5C2884"/a>/>
<>212 span =Heading> <span><h4
<>Theoperations are access ( a =chap21.tmljava.lang.StringIndexOutOfBoundsException: Range [98, 96) out of bounds for length 583
<p>The term basic operation means that each other list operation can be formulated in terms of the basic operations. (But note that often a more efficient method than this one is implemented.)</p>
<p>Any <strong class="pkg">GAP</strong> object <var class="Arg">list</var> in the category <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701Espan class=">br>span class"nocss&bsp;&java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 127
<p>For internally represented lists, kernel methods are provided for the basic list operations with positive integer indices. For other lists or other indices, >java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
<p><a id="X8297BBCD79642BE6" java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 7
<h5><code>21.2-1 <span>\</span>[<span>\</span>]</code></h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">an style='color: green'>8227;span"ContSS">br >spanclassnocss"&;;/>a="chap21.html#X78B72FDF7BD63C0B">21.5-3 Unbind</a></span>
<div class="func"><table class="<span>
< class="func">table java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 300
<iv=func">table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Unbind<span>\</span>[<span>\</span>]</code>( <var class="Arg">list</var>, <var class="Arg">ix</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>These operations implement element access, test for element boundedness, list element assignment, and removal of the element with index <var class="Arg">ix</var>.</p>
<p>Note that the special characters <code class="code">[</code>, <code class="code">]</code>, <code class="code">:</code>, and/
<class"ode">[(< class="">list<var,< "Arg"ix> to <class=code>varclass=Arg"></[< =Arg">ix</></code,which java.lang.StringIndexOutOfBoundsException: Range [211, 206) out of bounds for length 402
<p>Similarly, <code class="func">IsBound<span>\</span>[<span>\</span>]</code> is used explicitly mainly in method installations. In other situations, one can simply call <code class="func">IsBound</code> (<a href="chap21.html#X79EC565A7DCEC938"><span class="RefLink">21.5-1/span>
<>statements codeclass=func>></[span></]\=/> class""<pan\/>\/java.lang.StringIndexOutOfBoundsException: Range [155, 151) out of bounds for length 165
<p><a id="X7921047F83F5FA28" name="X7921047F83F5FA28"></a></p>
<>. span java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 56
<<class"code>var class"Arg>list</[<var=Arg>ix/var> </>/>
<p>The above construct java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 7
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5, 7, 11, 13 ];; < class"ContSS">br /<span ""  /span>a href=chap21html#"2112 </a</>
2
3
13
<></
<p>If <var class="Arg">list</var> is not a built-in list, or <var class="span>
<p><code class="code"><var class="Arg">list</var>{ <var class="Arg">poss</var> }</code></p>
<p>The above construct evaluates to a new list <var class="Arg">new</var> whose first element is <code class="code"><var class="Arg">list</var/span
<div class=</div></div>
<div =">span class="tocline"><span class="nocss"> </span><a href="chap21.html#X782ED7F27D8C7FC1">21.14 <span class="Heading"<>
<span class="GAPprompt">gap></span> <span class="GAPinput">l{[4..6]}; l{[1,7,1,8]};</span>
[, 11, 13 java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
[ 2, 17, 2, 19 ]
/></>
<p>The result is aspan>
<p>It is possible to nest such <em>sublist extractions</em>, as can be seen in the example below.</p>
<div class="example"><pre>
<span class=>
[ [ 3, 2 ], [ 6, 5 ], [ 9, 8 ] ]
<divjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 25
[ [ 7, 8, 9 ], [ 4, 5, 6 ] ]
</pre></div>
<p>Note the difference between the two examples. The latter extracts elements 1, 2, and 3 from <>
< =></>]/>or<">{varclass"Arg"poss/var>}</code> we associate a <em>level</em> that is defined as the number of selectors of the form <code class="code">{<var class="Arg">poss</var>}</code> to its left in the same expression. For example</p>
< class""< /<spanclass=nocss>nbsp;&<span<=.X7A122E848464E534"21- />/>
]poss2}java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 44
level 0 0 1 2 2 3
//divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
<pThena code""< class">/[var "></></of var "java.lang.StringIndexOutOfBoundsException: Range [133, 132) out of bounds for length 459
<div class="example"><pre>
ListElement := function ( list, pos, level )
if level
urnp];
else
return List( list, elm -> ListElement(elm,pos,level-1) );
fi;
end;
</pre></divdivclass""><ahref=chap21
< class"
<div class="example"><pre>
ListElements := function ( list, poss, level )
if level = 0 then
return list{poss};
else
return List( list, elm -> ListElements(elm,poss,level-1) );
fi;
end;
</pre></div>
<p><a id="X78791B8B838A8BA0" name="X78791B8B838A8BA0"></a></p>
<h5><code>21.3-1 \{\}</code></h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; \{\}</code>( <var class="Arg">list</var>, <var class="Arg">poss</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>This operation implements <em>sublist access<<panclass=C>br >< nocss>nbsp;nbsp;span>< =".html#X7C71596C82B6EF35">21.1-3 IsHomogeneousList</a></span>
p< ""name="></a>/p>
<h4>21.4 <span<span class="ContSS"<>spanclass=nocss>nbsp;n;<span>a href=".html#X7C84E16A85C99C8C">21.1-6 IsConstantTimeAccessList</a></span>
<p><code class"code"<var class="rg>list/var>[<varclass="Arg>ix</var ]: <ar class=Arg">object</var>;</code></p>
p> list theobject varclass=Arg"object</var> can ofany, to the =Arg"><var>in the mutable see< href".html
<div class="example"><pre>
<< class="ContSect"< class"">spanclass""&;/>a".html#X7921047F83F5FA28">21.3 <span class="Heading">List Elements</span></a>
spanclass=">&/>< ""l[]: ; l;
[ 2 ]
<class"ContSSBlock>
[3, 4, 5, 6 , ]
spanclass""gapgt;<span>span class="APinput"> : ; &;indexindex>maybean expression<spanjava.lang.StringIndexOutOfBoundsException: Index 132 out of bounds for length 132
[ 3, [ 4, 5, 6 ], 10 ]
</pre></div>
<p>If the/
<iv "xample>prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<"GAPinput">l4]: entry;l # <list> is enlarged</span>
[ /span>
< class=G">gapgt</pan>< class="APinput>[10 ]: 1;l; now&;listgt has a hole<span>
[ 3, [ 4, 5, 6 ], 10, "another entry",,,,,, 1 ]
<></divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
<p>The function <code class="func">Add</code> (<a href="chap21.html#X795EC9D67E34DAB0"><span class="RefLink">21.4-2</span></a>) should be used if you want to add an element to the end of the list.</p>
<p><
<p>Ifspanjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
/>
=ContSS>br >sclass=nocss"&&;<span>a href
<<span"ContSS"< >< class=nocss" /span>ahref"chap21.html#X84B383B97FD986CD">21.12-5 NestingDepthM</a></span>
<panclass"APprompt">></span>spanclass="GAPinput> : [ 2 3,5 11,13 17 19];/>
"GAPprompt">ap><span>< =GAPinput">{1.]}:= 10.]; ;</pan>
[10, 11,12,13, 11, , ,19
="GAPprompt"gap><span> <class="GAPinput">l{[1,7,1,10]} := [ 1, 2, 3, 4 ];; l;</span>
[ 3, 11, 12, 13, 11, 13, 2, 19,, 4 ]
</pre></div>
<p>The next example shows that it is possible to nest such sublist assignments.</p>
divclass=example"<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<< "">br/>span=nocss>nbsp;nbsp;<span<href=chap21html#X82EA2A5B786181C7">21.14-4 <span class="Heading">Division of lists</span></a>
<span >br /><span class=nocssass&;spana=chap21.tml
[ [ 1,< class""br/< =ontSS> <=;<> =html#X86DDC2FF7A50FBEE">21.22-1 IsRange</a></span>
</pre></div>
p behaviour
dx">
"java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 139
level 0 0 1 1 1 2
</pre></d=" toclinespan "&bsp;/>ahref"html
< =odevar=list/>[var class=Argvar : varclass=span class="ContSS"><br /><span class="nocss"> </span><a href="chap21.html#X7FA892828252BB3B">21.17-2 IsDuplicateFree
d class"">>
ListAssignment := functionp themostimportant toobjects
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
level then
listo] valsjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
classContSS>br<spanclass&;nbsp;span>< chap21html#X800209E881E7CECB">21.18-4 SortingPerm</a></span>
ListAssignment(h4>
od;
fijava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
end;
/>/div>
codeclass""< =">list<var>< =Arg>poss<var} : varclass"Argvals</var>/ var"levelvar "" < =Arg"/> var =Arg><var< =Arg>vals/ar>,varclass""level<var><code> [1 , 3]
>
ListAssignmentsdiv></div>
local i;
if<span>
list{} als;
else
for ijava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ListAssignments( list[i], poss, vals[i], level-1 );
djava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
fi;
end;
<></div>
<p><a <panjava.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 4
<>code21.1 {}\/java.lang.StringIndexOutOfBoundsException: Range [36, 31) out of bounds for length 37
ivclassfunc< func "%>java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 276
<p>This operation implements sublist assignment. For any list, the default method is to loop over the entries in the list <var class="Arg">poss</var>, and to java.lang.StringIndexOutOfBoundsException: Index 161 out of bounds for length 7
<p><a id="X795EC9D67E34DAB0" name="X795EC9D67E34DAB0"></a></p>
<h5>21.4-2 Add</h5>
<div class="func"><table< =C"< />span classspan =GAPprompt>ap&><anjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
<addstheelement varclassArgvartothemutablelist< =">/>.java.lang.StringIndexOutOfBoundsException: Range [100, 99) out of bounds for length 451
<p>The three argument version adds <var class="Arg">obj</var> in position <var class="Arg"java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
pNothing returned by code class""></code, the functionis onlycalled forits effect./
p<a &t;ist&;]have value
.- </h5>
div=func"<class"func "%>tr=tdleft>code =f">#
<p>java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 124
> form<
<div class="<>that valueofc=java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 446
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [ 2, 3, 5 ];; Add( l, 7 ); l;</span>
class">span""&;/a="html#X7D22B2298167A58F">21.22-3 ConvertToRangeRep</a></span>
="GAPinput"Add(,4,) java.lang.StringIndexOutOfBoundsException: Range [0, 76) out of bounds for length 0
,4sclass=</span ==">&<a href"html#X7BB462C17962647F">21.23-1 IsQuickPositionList</a></span>
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 84
4
[2,3,, 7 ]
< >pjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
7
[ 2, 3, 5 ]
> the to.A/emobjectsin .each apartial the totheofthelist .,java.lang.StringIndexOutOfBoundsException: Range [215, 214) out of bounds for length 542
[ 2, 3 5java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
</pre></div>
p< id=X79D7E96F80A2D7C0" name=
<h5>21.4-4 <p>Lists are used to implement seejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div classjava.lang.StringIndexOutOfBoundsException: Range [4, 2) out of bounds for length 216
<p>This function
ods forfor <codeclass""Add<>( =.html#X795EC9D67E34DAB0"><span class="RefLink">21.4-2</span></a>) and <code class="func">Remove</code> (<a href="chap21.html#X7E98B11B79BA9167"><span class="RefLink">21.4-3</span></a>).</p>
<p><a id="X79E31DB27C82D6E1" name="
<h5>21.4-5 Append</h5><</div>
div=func< =func"=100"<>td class=tdleft<pre<>
<>a id"" =""h5.-5 IsRectangularTable<h5
><Alist code=codeIsRectangularTable<code when isnonemptyandits are all java.lang.StringIndexOutOfBoundsException: Range [133, 132) out of bounds for length 169
class=">p> name=X7C84E16A85C99C8C>a</
<spanh5>1.-6IsConstantTimeAccessList<
[dtable" 100>>< =tdleft> =>#java.lang.StringIndexOutOfBoundsException: Index 234 out of bounds for length 234
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 97
[,3 ,11,13,17, java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
</pre></div>
<p><a id="X7963C8E17EFF86DB" name<span class="< are see =chap21tml#X7921047F83F5FA28"><span class="RefLink">21.3</span></a>), assignment of elements to a list (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>), fetching the length of a list (see <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>)), the test for a hole at a given position, and unbinding an element at a given position (see <a href="chap21.html#X7963C8E17EFF86DB"><span class="RefLink">21.5</span></a>).</p>
<h4>21.5 gap>
name=X79EC565A7DCEC938></a>/java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
<>21.- java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
class"java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 246
<pjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<ivclass"">pre>
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
true
<<aid= X80872FAF80EB5DF9<java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
false
<pan""gapgt;/sclass">( l101];/java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
false
</pre></div>
<p><a id="X866F45D3797FDA00<<class=>""/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<h5>21.5-2 GetWithDefault</h5>
classtdleft"class=unc>8227/>< ""/> java.lang.StringIndexOutOfBoundsException: Range [158, 157) out of bounds for length 283
<p><code class="func">GetWithDefault</code> returns java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
<p>While this method can be used on
<<><p>odeclassc><""><ar class""ar </</>
<div class="example"><java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
"java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
, ""
<span class="<p>But also otherenumerators s <
"a"
spanclass=APprompt"apt< classGAPinput"etWithDefault(, 2, )</>
2
<span class="GAPprompt">gap></span> <java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
""
<panclass=""gap<pan="gapgt<span span "> : [1,23] [,,] [,89
""
s =GAPprompt>&;/><span/<
<span class="GAPprompt">gap></span><h5>>code>.span><spanjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
false
</pre></div>
p<classf>table=unc %<< < class"&8227; <span>\</span>[<span>\</span>]\:\=</code>( <var class="Arg">list</var>, <var class="Arg">pos</var>, <var class="Arg">ix</var> )</td><td class="tdright">( operation )</td></tr></table></div>
h>.5- <java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22
div=func>java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
>=func><> the ""n/ mutable var=><.That of< ""/> <classArglistvar longer value < java.lang.StringIndexOutOfBoundsException: Range [0, 284) out of bounds for length 0
<div class="example"><pre>
<span
<span if =
[ ,, 5,7,, 11]
<span class="GAPprompt">gap&/>/iv>
[,2,,7, ]
;
>thatclass""<>(href"hjava.lang.StringIndexOutOfBoundsException: Index 537 out of bounds for length 537
<p><a id="X7DD65BEA7EDB0CD7" name="X7DD65BEA7EDB0CD7"></a></p>
h>.6<pan class=Heading> />h4>
<p>With the list assignment (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p
div class="<span class="GAPpromptgap;/><spanclass=GAPinput"m = 12,3], 45,6,[789,[1011java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
: 3;
i :
pheelementjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 465
<p>But in this example it>/> <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
""<>
l := [ 1, 2 ];
l := [< =GAPprompt"<> < "var=list/>< class""<><> var=java.lang.StringIndexOutOfBoundsException: Range [126, 125) out of bounds for length 459
<re>div>
psecond changethe ,instead anew to java.lang.StringIndexOutOfBoundsException: Range [103, 102) out of bounds for length 234
< iflevel = 0then
l := [ 1, 2 ];
l[3] := 3;
</pre></div>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>
l1 fi ""listvardoesnot list,var =Arg<vardoes evaluate , java.lang.StringIndexOutOfBoundsException: Index 144 out of bounds for length 0
l2 := l1;
l1 := [ 1, ,3]
</
<p>But after the java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
<div class="example"><pre>
= 12 java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
l2 =l1
l1[</pre><div
</pre></div>
<p/</>
Letunder two areidentical.<p< class=GAPprompt>></>< =GAPinput>m{[1,2,3]}{[3,2]} := [ [11,12], [13,14], [15,16] ];; m;</span>
pIfenteralistliteral java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 271
<div class=
l1 := [ 1, 2 otejava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 286
l2 := [ 1, 2 ];
</pre></div<> varclass"><var a ,< ""<vardoesnottopositiveinteger java.lang.StringIndexOutOfBoundsException: Range [148, 147) out of bounds for length 565
<>infollowing in codecode>are./
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 26
l : 12 .(list java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
forpThenextexample itisjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 4
</pre></div>
<p>If you assign a list to a variable no new list is created. Thus the list value ofjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 5
l1 := [ 1, 2 ];
l2 := l1;
</pre></div>
<p>If you pass a list as an java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="example"><pre>
=[1,2]
f := function ( l ) return l; end;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
</pre></div>
> listit lists one the handtwojava.lang.StringIndexOutOfBoundsException: Range [209, 208) out of bounds for length 418
<java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
l1 := [ 1, 2 ];
l2 := l1;
l1[1] := 2;
</pre></div>
pa"Ejava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62
<h4>21.7 <span class="Heading">Duplication of<> argument formalways theremoved element.In <classA"l/ must be empty<>
<>Herewedescribethe of c class=java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
<p>You maythink that thefollowing example thesecond assignment the .<p>
> forany var =Arg"list/> <odeclass"func"ShallowCopy/ (a href"chap12.#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) returns a mutable <em>new</em> list <var class="Arg">new</var> that is <em>not identical</em> to any other list (see <a href="chap21.html#X7DD65BEA7EDB0CD7"><span class="RefLink">21.6</span></a>), and whose elements are identical to the elements of <var class="Arg">list</var>.</p>
<p>Analogously, for a <em>mutable</em> list <var class="Arg"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>In both cases/<>
<p><code class="func">ShallowCopy<<>Butafter following example list class=code></>isa name has changedand thus the value <code class=code></code> is <class="ode> 1 ,3]/java.lang.StringIndexOutOfBoundsException: Range [205, 204) out of bounds for length 210
<div class="example"><pre>
new := [];
for i in [pWesaythat two lists are emidentical<em> if changing one of them by listassignment also the one This slightly ,becauseif<em><em> names <><emlist , correctusagewould be very awkward and onlyadd that two listsbeequal is one withtwo names.Thusidentityisanequivalence arefinement of equality.Identity objects can detectedusing classf"java.lang.StringIndexOutOfBoundsException: Range [590, 589) out of bounds for length 683
if IsBound( list[i] ) then
new[]=listi;
fi;
od;
iv
classexample>>
<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< in 1.10]do[i : [1 2 ]
false
spanclassgap<>< =java.lang.StringIndexOutOfBoundsException: Range [76, 60) out of bounds for length 106
true
<span class= , java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
,[ 3 ] java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
[ , ]
</pre></div>
p""StructuralCopy</ode>(ahref="chap12.html#X7C1E70587EBDD2CB"><span class="RefLink">12.7-2</span></a>) basically executes the following code for lists.</p>
<div class="example"><pre>
new := [];
for
if IsBound( list[i] ) then
new[i] := StructuralCopy( list[i] );
fi;
od;
</pre></div>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">list1 := [ [ 1, 2 ], [ 3, 4 ] ];; list2 := StructuralCopy( list1 );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj( list1, list2 );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj( list1[1], list2[1] );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">list2[1][1] := 0;; list1; list2;</span>
[ [ 1, 2 ], [ 3, 4 ] ]
[ [ 0, 2 ], [ 3, 4 ] ]
</pre></div>
<p<divclass=""<pre>
="><prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
">gapgt;/span span ="APinput"sub:=[1 2 ];list1 := [ sub, sub ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">list2 := StructuralCopy( list1 );</span>
[ [1 2 ] [1,2 ]
<span class="GAPprompt">gap><
<divclass="example"><pre>
<span class="GAPprompt">gap></span> <spanpa=X7ED7C0738495556Fname"">a<pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
[[1 2 ,[1 java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
</pre></div>
p> id=X808A207182B2F84FnameX808A207182B2F84F"<a</>
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
<p><a id="X7B914A287F88ED0A" name="X7B914A287F88ED0A"></a></p>
<><>2181 icode/>
<div classcodeclass""><code (a href=chap12.#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>) basically executes the following code for lists.</p>
<p>This java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>If the list <var class="java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 26
<div od;
="GAPprompt>gap>/span><span class=GAPinput"1in[2, ,1, ;
true
false
s class ;
< class=GAPprompt"gap&t<span <span class=GAPinput"IsIdenticalObj list1,java.lang.StringIndexOutOfBoundsException: Range [91, 90) out of bounds for length 100
false
</pre></div>
ref".#X8196FD4779BCCA0C"><span class="RefLink">21.16</span></a>.</p>
<p><a id="X84D6FC7E7E39ED33" name="X84D6FC7E7E39ED33"></a></p>
h49span lass"" InternallyRepresented />4
> ahref
i 1f class"gap/> < class=GAPinput"list21 : ; list1 list2;/>
<p>On the other hand suppose every <re<iv
<p>So the following strategyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<">>/ span =G"(list1,list2 ;/span>
< <if
fine code dealing with plain lists java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 3
<p><a id="X78BF67A5802E93AD" name=
5.1<<java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
<div class="func"><table class="func" width="<div class=example"><pre>
<p>Returns: a plain list</p>
divsan class=APpromptgapg;</pan><span =GAPinput"list2: StructuralCopy( list1 );</span>
<p>Returns: nothing</p>
<p>The function <code class="func">[[0 ,[,2 java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
function< ShrinkAllocationPlist> <classpkg></trong>s memory manager physical memorywhichisallocatedfor java.lang.StringIndexOutOfBoundsException: Range [185, 180) out of bounds for length 263
<p>Note that therejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="example<<a=
<span
[ ]
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
> <span class"GAPinput"># now l uses about 25% more memory than the equal list m</span>
<span class="GAPprompt">gap></span> <span class [12 ], [ , 2 ]
spanclass"GAPprompt"gap></pan><span class=GAPinputjava.lang.StringIndexOutOfBoundsException: Index 112 out of bounds for length 12
</pre></div>
<p><a java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
<h4>21.10 <span class="Heading
<p><java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><code class="code"><var<iv java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 4
> <ar class""list2</varareequalifandonlyif every index <pan ="SimpleMath"></>,eitherbothentries <var class="Arg">list1</var><span class="SimpleMath">[i]</span> and<pan =GAPpromptgap>/span>< class=GAPinput> in ;# uses binary search and only 4 comparisons</span>
<div class="example"><pre>
<span class="GAPprompt"><>aid"84D6FC7E7E39ED33" name=X84D6FC7E7E39ED33"</a></p>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">[ , 2, 3 ] = [ 1, 2, ];</span>
false
<class""gapgt;/ s class=GAPinput"[ 1,2 3 ]=[3 ]/java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
false
v>
causeproblems with lists which are java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><code class="code"><var class="Arg">list1</var> < <var class="Arg">list2</
<p><code class="code"><var class="Arg">list1</var> <= <var class="Arg">java.lang.StringIndexOutOfBoundsException: Range [0, 79) out of bounds for length 0
<>Unboundare thanboundentry implies following . ""<span bethesmallestpositiveinteger<span=SimpleMathi/>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="example">p> result thisisof <p>The result of this is of course
<span class="GAPprompt">gap></span> <span class="GAPinput">[pSuppose codeclass=funcLength<><ahrefjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ue
<span class="GAPpromptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rue
<span class="GAPprompt">gap></span> <span class=<div class=func>table java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
true
</pre></div>
p>ote that comparingtwo withcclass="code"&;/ <java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 23
<"<a</>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>It is convenient to have arithmetic operations for listsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>(Due to the intended generality<p>ote that aresimilar < class=func"EmptyString</ <href"chap27html"< =Rjava.lang.StringIndexOutOfBoundsException: Index 136 out of bounds for length 0
<p>For <divclass="example><pre>
<<spanclass=GAPprompt>ap&t</pan <span =GAPprompt>gap&<span <java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 113
<p>For the definition "gap>/span> span=GPinput"m=EmptyPlist160 iin[1.160 doAdd(,i2) ;<span
<p>For the mutability <span class="APprompt>&;/span < class="GAPinput"># now l uses about 25% more memory than the equal list m</span>
<> details specialcases rowvectors and < class=GAPprompt">gap&t;/span>< java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 125
"></</>
<h4>21"> /
<<codeclass=code>varclass="Arg"list1</ar <class"rg>list2<var</code>/p>
pNote
<p><a id=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<h5>21.12-1 IsGeneralizedRowVector</h5>
div<vclassexample""<pre
<p>For a<ivclass="example"><pre>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"< class""<span>< class""> 1,2 ] =[1 2, ;/spanjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
true
false
<span class="GAPprompt">gap></span> <span class="GAPinput">liemat:= LieObject( [ [ 1, 2 ], [ 3, 4 ] ] );</span>
LieObject( [ [ 1, 2 ], [ 3, 4 ] ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">IsGeneralizedRowVector( liemat );</span>
<span =">&;</span> <span =GAPinput> 1 2 3 ] [3 2,1]<spanjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
< definition cause areown such for equality may toaninfiniterecursion intheif list to java.lang.StringIndexOutOfBoundsException: Range [207, 206) out of bounds for length 314
<p><a id="<p><code class="code"><var ""list1<var> &t<classArg"list2/>//p>
<h5>21.12-2 IsMultiplicativeGeneralizedRowVector</h5>
divclass<Lareordered<emlexicographicallyem. entries entry the behaviour.Letspanclass""i/span>bethejava.lang.StringIndexOutOfBoundsException: Range [191, 190) out of bounds for length 1003
<p>For a
<div class="example"><prejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
false
<span class="GAPprompt">gap></span> <span class="GAPinput">< class="">>> <panclass""[ 1,,3 4 ] &;[1 -1 ] &t;>2 is and lt -1<spanjava.lang.StringIndexOutOfBoundsException: Index 149 out of bounds for length 149
<pNote forcomparing listswith code =code>;codeor codeclass""<<code, the r)listelements must comparable < class=java.lang.StringIndexOutOfBoundsException: Range [180, 179) out of bounds for length 499
<span class="GAPprompt">gap></span>pa=X845EEAF083D43CCEname=X845EEAF083D43CCE>/<>
true
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
> that filters <code class=func>IsGeneralizedRowVector<<> the flexibility arequitetechnical. not toocases matrices see a=chap24.html
<p><a id="X7BAD12E67BFC90DE" name="X7BAD12E67BFC90DE"></a></p>
<h5>21java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
div=func>t =" width"%>tr< => =&8227 /java.lang.StringIndexOutOfBoundsException: Range [128, 127) out of bounds for length 223
>avar=><var,<odeclass="unc><code>indicates java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 0
<p>Fortheofreturnvalues multiplicativeoperations whose argumentsare these,see< hrefc.#java.lang.StringIndexOutOfBoundsException: Index 426 out of bounds for length 426
<p>All internally represented lists are in this category, and also all lists in the
<div =example>pre
<span class="GAPprompt
<p<id"java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62
true
< classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
true
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></div>
<p><a id="X8428E77B86722D52" name="java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
<h5>21.12-4 NestingDepthA<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="func
<java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
<p><a id="X84B383B97FD986CD" LieObject( [ [ 1, 2 ], [ 3, 4 ] ] )
<h5>21.12-5 NestingDepthM</h5>
<>2112- java.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 53
pFora<classpkg><strong object varclass""/><code NestingDepthMcodereturnsthe>depth/><class""obj/> recursively spanclass="<>if <varclass""></> in <codeclassfunc>IsMultiplicativeGeneralizedRowVector<code(a=chap21htmlX7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), as the integer <span class="SimpleMath">1</span> if <var class="Arg">obj</var> is an empty list in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), and as <span class="SimpleMath">1</span> plus the multiplicative nesting depth of the first bound entry in <var class="Arg">obj</var> otherwise.</p>
<div class="example"><pre>
s"java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 109
1
1
class"GAPprompt"gapgt;span><panclass=GAPinput">(m ); ( m )<spanjava.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( liemat ); NestingDepthM( liemat
2
0
<span class="GAPprompt"><< "java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 62
class>&;span"">l1) NestingDepthM );</panjava.lang.StringIndexOutOfBoundsException: Index 111 out of bounds for length 111
2
2
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l2 ); NestingDepthM( l2 );</span>
1
1
</span=GAPprompt"gapgt<span>
<p><a id="X7E6A1F66781BE923" name="X7E6A1F66781BE923"></a></p>
<h4>21.13 <span class="Heading">Additive Arithmetic for Lists</span></h4>
< class=GAPprompt"gapgt</><span class="GAPinput">v:= [ 1, 2 ];; m:= [ v, 2*v ];;</span>
<pjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
<>aid"X86A85ADC85C451DC" name="86>>/>
<h5>21.13-1 <span class="Heading">Zero for lists</span></h5>
<p>The zero (see <code class="func">Zero</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>)) of a list <span class="SimpleMath">x</span> in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) is defined as the list whose entry at position <span class="SimpleMath">i</span> is the zero of <span class="SimpleMath">x[i]</span> if this entry is bound, and is unbound otherwise.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Zero( [ 1, 2, 3 ] ); Zero( [ [ 1, 2 ], 3 ] ); Zero( liemat );</span>
[ 0, 0, 0 ]
[ [ 0, 0 ], 0 ]
LieObject( [ [ 0, 0 ], [ 0, 0 ] ] )
</pre></div>
<p><a id="X7B91CE4D814C2D08" name="X7B91CE4D814C2D08"></a></p>
<h5>21.13-2 <span class="Heading">AdditiveInverse for lists</span></h5>
<p>The additive inverse (see <code class="func">AdditiveInverse</code> </re>div>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span<>< id" =X7FBCA5B58308C158">/>/p>
[ -1, =func> class =%>>td =>""java.lang.StringIndexOutOfBoundsException: Index 246 out of bounds for length 246
2]
</pre></div>
<p><a id="X842D123E7EE5E3DB" name="X842D123E7EE5E3DB"></a></p>
<h5>21.13-3 <span class="Heading"java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
<p>If <span class="SimpleMath">x</span> and <span class="SimpleMathp a list var=Argjava.lang.StringIndexOutOfBoundsException: Index 291 out of bounds for length 291
<p>If java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="example"><pre>
<span class="GAPprompt">java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
[ 2,
[ 1, " "java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 62
[ 0*Z(2), 2 ]
l2:= [ , 2 3 4 5 ;<span>
<span class="GAPprompt">gap></span> <span class="GAPinput">l3java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="GAPinput">NestingDepthA( l1 ); div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func
1
1
<span class="GAPprompt">gap></span> <span<iv ="example"><pre>
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
2
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 + l2;</span>
[ java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<span class="GAPprompt">gap>"APprompt">gt;/><panclass=GAPinput>(l1 ; java.lang.StringIndexOutOfBoundsException: Range [98, 97) out of bounds for length 111
[ [ 2, 2, 3, 4 ],, [ 6, 6, 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l2 + l4;</span>
[ , [ 3, 6, 3, 4,
<span class="GAPprompt">gap></span> <span class="GAPinput">l3 + l4;</span>
,2] , [ 10 java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 + [];</span>
[ 1,, 3, 4 ]
</pre></div>
<p><a id="X7C3DC8BE78DEECDE" name="X7C3DC8BE78DEECDE"></a></p>
<h5>21.13-4 <span class="Heading">Subtraction of lists</span></h5>
=""GAP" one in="IsGeneralizedRowVector<code>(ahref=chap21html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and the other is also in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) or is neither a list nor a domain, <span class="SimpleMath">x - y</span> is defined as <span class="SimpleMath">x + (-y)</span>.</p>
<div class="java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 12
<span class="GAPprompt"><pTheadditiveinverse ( <code ="unc"AdditiveInverse<code (a href"chap31.html#X84BB723C81D55D63"><span class="RefLink">31.10-9</span></a>)) of a list <span class="SimpleMath">x</span> in <code class="func">IsGeneralizedRowVector</code> (<a href="chap21.html#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) is defined as the list whose entry at position <span class="SimpleMath">i</span> is the additive inverse of <span class="SimpleMath">x[i]</span> if this entry is bound, and is unbound otherwise.</p>
[ 1, -2, 0, 0, -5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 - l3;</span>
[ [ 0, -2, 3, 4 ],, [ -4, -6, 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l2 - l4;</span>
[ , [ -3, -2, 3, 4, 5 ], [ -5, -4, 3, 4, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l3 - l4;</span>
[ [ 1, 2 ], [ -3, -4 ], [ 0, 0 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l1 - [];</span>
[ 1,, 3, 4 ]
</pre></div>
<p><a id="X782ED7F27D8C7FC1" name="X782ED7F27D8C7FC1"></a></p>
<h4>21.14 <span class="Heading">Multiplicative Arithmetic for Lists</span></h4>
<p>In this general context, we define the results of multiplicative operations only in the following situations. For unary operations (one and inverse), the unique argument must be in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>); for binary operations (multiplication and division), at least one argument must be in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>), and the other either not a list or also in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>).</p>
<p>(For non-list <strong class="pkg">GAP</strong> objects, defining the results of unary operations is not an issue here, and if at least one argument is a list not in <code class="func">IsMultiplicativeGeneralizedRowVector
<p><a id="X79A8A5627FD42FA5" name="X79A8A5627FD42FA5"></a></p>
<h5>21.14-1 <span class="Heading">One for lists</span></h5>
<p>The<class=GAPprompt">ap&;/span><span class="APinput">AdditiveInverse ,2 3] ); AdditiveInverse( [ [ 1, 2 ], 3 ] );</span>
<div class="example"><pre>
class=GAPprompt>gap&t<span spanclass"GAPinput">One([ [ 1 2 ] [3, 4 ;</span>
[ [ 1, 0 ], [ 0, 1 ] ]
<span <h5>21.133 <pan class="eading"Addition of lists</span></h5>
[ [ [ [ 1 ] ], [ [ 0 ] ] ], [ [ [ 0 ] ], [ [ 1 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</pre></<p>If <spanclass"SimpleMath></span>and< class=SimpleMath>y/span arein<code="func>IsGeneralizedRowVector/code>(ahref=chap21.tml#X87ABCEE9809585A0"><span class="RefLink">21.12-1</span></a>) and have the same additive nesting depth (see <code class="func">NestingDepthA</code> (<a href="chap21.html#X8428E77B86722D52"><span class="RefLink">21.12-4</span></a>)), the sum <span class="SimpleMath">x + y</span> is defined <em>pointwise</em>, in the sense that the result is a list whose entry at position <span class="SimpleMath">i</span> is <span class="SimpleMath">x[i] + y[i]</span> if these entries are bound, is a shallow copy (see <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>)) of <span class="SimpleMath">x[i]</span> or <span class="SimpleMath">y[i]</span> if the other argument is not bound at position <span class="SimpleMath">i</span>, and is unbound if both <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> are unbound at position <span class="SimpleMath">i</span>.</p>
<p><a id="X78C6C1E2849D303A" name="X78C6C1E2849D303A"< >&;/>span=> ;spanjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
<h5>21.14-2 <span [ , , ,4] , ]
<p>>
divclass="xample">>
<span class="GAPprompt">gap></span> <span class="GAPinput">java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[[-2, 1 ] [ 3/,-1/ java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
</pre></div>
<><a id="X84FDB95179BFE4CDname"X84FDB95179BFE4CD"a>pjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
<h5>21.14-3 <span class="Heading">Multiplication of lists
<p>There are three possible computations that might be triggered by a java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 0
<dl>
classGAPprompt>gt>s="""ne([[, ][3,]])/spanjava.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
<dd><p>the inner product <span class= 1] ][[0]],[[[0]], 1 ]java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
</dd>
<dt><strong class="Mark">(L)</strong></dt>
<dd><p>the left scalar multiple, i.e., a list whose entry at <>< =X78C6C1E2849D303A" name"X78C6C1E2849D303A"<a>/>
<java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
dd> right multiple,.e, list entry position< =SimpleMath></span spanclass="impleMath"x]*y/>if ""x/span>isboundatposition <span class=SimpleMath></span, isunbound if .<p>
</dd>
</dl>
p>uraim is to generalizethebasic arithmetic of simple vectors and matrices, so we first summarize the situations that shall be covered.</p>
<div class="pcenter"><table class="GAPDocTable">
<tr>
< class="dcenter>/d>
<td class="tdcenter">scl</td>
<td class="tdcenter">vec</td>
<td java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
</tr>
<tr>
<td class="tdcenter">scl</td>
<td class="tdcenter"><>< class=Mark>I<strong>/
<td class="tdcenter">(L)</td>
<td class"tdcenter"()/d
</tr>
<tr>
class<java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
<td class="java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 5
<td class="tdcenter">(I)</td>
<td ="tdcenter">I)/td>
</tr>
<tr>
<td class="tdcenter">mat</td>
<td class="tdcenter">(R)</td>
<td class="tdcenter">(R)</td>
<td class="tdcenter">(R)</td>
</tr>
</table><br />
</div>
Thismeans for a()avector() ( L that isjava.lang.StringIndexOutOfBoundsException: Range [158, 157) out of bounds for length 162
<p>Now we can state the general multiplication rules.</p>
<p>If exactly one argument is in <code class="func"< =>)/java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
<p>In the remaining cases,td class""()/>
<p>So <> >
<>If argumenthasodd depthis a has depthandjava.lang.StringIndexOutOfBoundsException: Range [138, 135) out of bounds for length 305
<p>We are left with the case that each argument has even multiplicative nesting depth. If
<div class<
">gap;<span span class="GAPinput">[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ] * (1,4);</span>
[ (1,4), (1,4)(2,3), (1,2,4), (1,2,3,4), (1,3,2,4), (1,3,4) ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, , 4 ] * 2;</span>
[ 2, 4,, 8 ]
span="GAPprompt"gap spanclass=GAPinput> 1 2,3]* [ 1, 3, 5, 7]/span>
22
<span class="GAPprompt">gap></span> <span class="GAPinput">m:= [ [ 1, 2 ]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
,,[[3 ,9]]
<span class="GAPprompt">gap></span> <span class="GAPinput">m * m = [ m[1,,,)]
true
<<panclass"gapgt;/><pan =GAPinput"[1 , , 4 ] *2<span>
14
<java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
true
</pre></div>
<p><a id="X82EA2A5B786181C7spanclass=GAPprompt>gt;<span> <pan class="GAPinput"> *m = [ [1 m,m[2 *m </java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
<h5>21.14-4 <span class="Heading">Division14
<p>For#X7FBCA5B58308C158
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 1, 2, 3 ] /
[ 1/2, 1, 1/, 1,3/ java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
[ 1, 0 ]
</pre></div>
<p><a id="X7A0FD70C80B95C00" name="X7A0FD70C80B95C00"></a></p>
<h5>21.14-5 <span class="Heading">mod for lists</span></h5>
<p>If <var class="Arg">x</var> and <var class="Arg">y</var> are in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and have the same multiplicative nesting depth (see <code class="func">NestingDepthM</code> (<a href="chap21.html#X84B383B97FD986CD"><span class="RefLink">21.12-5</span></a>)), <code class="code"><var class="Arg">x</var> mod <var class="Arg">y</var></code> is defined <em>pointwise</em>, in the sense that the result is a list whose entry at position <span class="SimpleMath">i</span> is <code class="code"><var class="Arg">x</var>[i] mod <var class="Arg">y</var>[i]</code> if these entries are bound, is a shallow copy (see <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>)) of <span class="SimpleMath">x[i]</span> or <span class="SimpleMath">y[i]</span> if the other argument is not bound at position <span class="SimpleMath">i</span>, and is unbound if both <span class="SimpleMath">x</span> and <span class="SimpleMath">y</span> are unbound at position <span class="SimpleMath">i</span>.</p>
<p>If <span class="SimpleMath">x</span> is in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and <span class="SimpleMath">y</span> is in <code class="func">IsMultiplicativeGeneralizedRowVector</code> (<a href="chap21.html#X7FBCA5B58308C158"><span class="RefLink">21.12-2</span></a>) and has lower multiplicative nesting depth or is neither a list nor a domain, <code class="code"><var class="Arg">x</var> mod <var class="Arg">y</var></code> is defined as a list whose entry at position <span class="SimpleMath">i</span> is <code class="code"><var class="Arg">x</var>[i] mod <var class="Arg">y</var></code> if <var class="Arg">x</var> is bound at position <span class="SimpleMath">i</span>, and is unbound if not. The equivalent holds in the reversed case, where the order of the arguments is kept.</p>g/java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 103
<div class="example"><pre>
spanGAPpromptgapgt<span span=""> mod[2 3,5 ;/>
[ 1, 1,, 1, 0 ]
<span class="GAPprompt">gap></span> <span class<pan class=GAPprompt>&;/><class=GAPinput"P( ,IsPrimeInt )</>
[ 2, 0, 1, 2, 0 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">[ 10, 12, 14, 16 ] mod [ 3, 5, 7 ];</span>
[ 1, 2, 0, 16 ]
</pre></div>
<p><a id="X84BB2DFB8432A1A4" name="X84BB2DFB8432A1A4"></a></p>
<h5>21.14-6 <span class="Heading">Left quotients of lists</span></h5>
<p>For two <<>aid"X86C9E5C3863B3C03"=X86C9E5C3863B3C03</a<p>
<div class="example"><pre>
<span class="GAPprompt">gap>< ="unc"< ""width=100%>tr< class"">code=func&8227; PositionBound</code>( <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
[ 0, 1/2 ]
</pre></div>
<p><a id="X8676EFE67972FD06" name=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<h4>21.15 <span class="Heading">Mutability Status and List Arithmetic</span></h4>
<p>Manyresults , lists,are lists, is whethertheir entriesare ornot (f).Note that the mutability of the itselfis by general rule any result of anarithmetic,notonly see< href".java.lang.StringIndexOutOfBoundsException: Range [404, 359) out of bounds for length 404
<p><span class"; class""java.lang.StringIndexOutOfBoundsException: Range [77, 75) out of bounds for length 93
<p>Thus a fully mutable matrix
<p>The immutability level of the result of any of the binary operations discussed here is the minimum of the immutability levels of the argumentsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p>Moreover,<div "func"table"func"width100>tr< java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 224
div class=>pre
<p>For example, the sum of< ""gapgt/ spanGjava.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 93
<p>For unaryjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
"><prejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
>gap<> spanclass">IsMutable );IsMutable(2 ( 1, 2 3] ))<span>
true
false
<span lass=""<table =func 100%<>"java.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 281
true
true
<<div>
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<p><a id="X80FDB1457FF582E7" <h5>21.16-14 PositionNonZero</h5>
.1h5
<div class="func"><table class="func" width="100%"><tr>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListWithIdenticalEntries( 10, 0 );</span>
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
</pre></div>
<p><a id="X8196FD4779BCCA0C" name="X8196FD4779BCCA0C"></a></p>
<h4>21.16 <span class="Heading">Finding Positions in Lists</span></h4>
<p><a id="X79975EC6783B4293" name="X79975EC6783B4293"></a></p>
<h5>21.16-1 Position</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; Position</code>( <var class="Arg">list</var>, <var class="Arg">obj</var>[, <var class="Arg">from</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>returns the position of the first occurrence <var class="Arg">obj</var> in <var class="Arg">list</var>, or <code class="keyw">fail</code> if <var class="Arg">obj</var> is not contained in <var class="Arg">list</var>. If a starting index <var class="Arg">from</var> is given, it returns the position of the first occurrence starting the search <em>after</em> position <var class="Arg">from</var>.</p>
<java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0 | | |