{"route":"/en-US-v0.14.1/reference/foundations/array/","title":"Array","description":"Documentation for the Array type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"constructor","name":"Constructor","children":[{"id":"constructor-value","name":"value","children":[]}]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-len","name":"Length","children":[]},{"id":"definitions-first","name":"First","children":[{"id":"definitions-first-default","name":"default","children":[]}]},{"id":"definitions-last","name":"Last","children":[{"id":"definitions-last-default","name":"default","children":[]}]},{"id":"definitions-at","name":"At","children":[{"id":"definitions-at-index","name":"index","children":[]},{"id":"definitions-at-default","name":"default","children":[]}]},{"id":"definitions-push","name":"Push","children":[{"id":"definitions-push-value","name":"value","children":[]}]},{"id":"definitions-pop","name":"Pop","children":[]},{"id":"definitions-insert","name":"Insert","children":[{"id":"definitions-insert-index","name":"index","children":[]},{"id":"definitions-insert-value","name":"value","children":[]}]},{"id":"definitions-remove","name":"Remove","children":[{"id":"definitions-remove-index","name":"index","children":[]},{"id":"definitions-remove-default","name":"default","children":[]}]},{"id":"definitions-slice","name":"Slice","children":[{"id":"definitions-slice-start","name":"start","children":[]},{"id":"definitions-slice-end","name":"end","children":[]},{"id":"definitions-slice-count","name":"count","children":[]}]},{"id":"definitions-contains","name":"Contains","children":[{"id":"definitions-contains-value","name":"value","children":[]}]},{"id":"definitions-find","name":"Find","children":[{"id":"definitions-find-searcher","name":"searcher","children":[]}]},{"id":"definitions-position","name":"Position","children":[{"id":"definitions-position-searcher","name":"searcher","children":[]}]},{"id":"definitions-range","name":"Range","children":[{"id":"definitions-range-start","name":"start","children":[]},{"id":"definitions-range-end","name":"end","children":[]},{"id":"definitions-range-step","name":"step","children":[]}]},{"id":"definitions-filter","name":"Filter","children":[{"id":"definitions-filter-test","name":"test","children":[]}]},{"id":"definitions-map","name":"Map","children":[{"id":"definitions-map-mapper","name":"mapper","children":[]}]},{"id":"definitions-enumerate","name":"Enumerate","children":[{"id":"definitions-enumerate-start","name":"start","children":[]}]},{"id":"definitions-zip","name":"Zip","children":[{"id":"definitions-zip-exact","name":"exact","children":[]},{"id":"definitions-zip-others","name":"others","children":[]}]},{"id":"definitions-fold","name":"Fold","children":[{"id":"definitions-fold-init","name":"init","children":[]},{"id":"definitions-fold-folder","name":"folder","children":[]}]},{"id":"definitions-sum","name":"Sum","children":[{"id":"definitions-sum-default","name":"default","children":[]}]},{"id":"definitions-product","name":"Product","children":[{"id":"definitions-product-default","name":"default","children":[]}]},{"id":"definitions-any","name":"Any","children":[{"id":"definitions-any-test","name":"test","children":[]}]},{"id":"definitions-all","name":"All","children":[{"id":"definitions-all-test","name":"test","children":[]}]},{"id":"definitions-flatten","name":"Flatten","children":[]},{"id":"definitions-rev","name":"Reverse","children":[]},{"id":"definitions-split","name":"Split","children":[{"id":"definitions-split-at","name":"at","children":[]}]},{"id":"definitions-join","name":"Join","children":[{"id":"definitions-join-separator","name":"separator","children":[]},{"id":"definitions-join-last","name":"last","children":[]},{"id":"definitions-join-default","name":"default","children":[]}]},{"id":"definitions-intersperse","name":"Intersperse","children":[{"id":"definitions-intersperse-separator","name":"separator","children":[]}]},{"id":"definitions-chunks","name":"Chunks","children":[{"id":"definitions-chunks-chunk-size","name":"chunk-size","children":[]},{"id":"definitions-chunks-exact","name":"exact","children":[]}]},{"id":"definitions-windows","name":"Windows","children":[{"id":"definitions-windows-window-size","name":"window-size","children":[]}]},{"id":"definitions-sorted","name":"Sorted","children":[{"id":"definitions-sorted-key","name":"key","children":[]},{"id":"definitions-sorted-by","name":"by","children":[]}]},{"id":"definitions-dedup","name":"Deduplicate","children":[{"id":"definitions-dedup-key","name":"key","children":[]}]},{"id":"definitions-to-dict","name":"To Dict","children":[]},{"id":"definitions-reduce","name":"Reduce","children":[{"id":"definitions-reduce-reducer","name":"reducer","children":[]}]}]}],"body":{"kind":"type","content":{"name":"array","title":"Array","keywords":[],"oneliner":"A sequence of values.","details":"<p>A sequence of values.</p>\n<p>You can construct an array by enclosing a comma-separated sequence of values\nin parentheses. The values do not have to be of the same type.</p>\n<p>You can access and update array items with the <code>.at()</code> method. Indices are\nzero-based and negative indices wrap around to the end of the array. You can\niterate over an array using a <a href=\"/en-US-v0.14.1/reference/scripting/#loops\">for loop</a>. Arrays can be\nadded together with the <code>+</code> operator, <a href=\"/en-US-v0.14.1/reference/scripting/#blocks\">joined together</a>\nand multiplied with integers.</p>\n<p><strong>Note:</strong> An array of length one needs a trailing comma, as in <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span><span class=\"typ-punct\">)</span></code>.\nThis is to disambiguate from a simple parenthesized expressions like <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span> <span class=\"typ-op\">+</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">*</span> <span class=\"typ-num\">3</span></code>. An empty array is written as <code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span></code>.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> values <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">7</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-op\">-</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">0</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span>values<span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">0</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">-</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">find</span><span class=\"typ-punct\">(</span>calc<span class=\"typ-punct\">.</span>even<span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">filter</span><span class=\"typ-punct\">(</span>calc<span class=\"typ-punct\">.</span>odd<span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">map</span><span class=\"typ-punct\">(</span>calc<span class=\"typ-punct\">.</span>abs<span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">values</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">rev</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">flatten</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;C&quot;</span><span class=\"typ-punct\">)</span>\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">join</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;, &quot;</span><span class=\"typ-punct\">,</span> last<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot; and &quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/b82dcffb69c678f6966654cb6a9894a3.png\" alt=\"Preview\"></div></div>","constructor":{"path":[],"name":"array","title":"Construct","keywords":[],"oneliner":"Converts a value to an array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Converts a value to an array.</p>\n<p>Note that this function is only intended for conversion of a collection-like\nvalue to an array, not for creation of an array from individual items. Use\nthe array syntax <code>(1, 2, 3)</code> (or <code>(1,)</code> for a single-element array) instead.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> hi <span class=\"typ-op\">=</span> <span class=\"typ-str\">&quot;Hello 😃&quot;</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">array</span><span class=\"typ-punct\">(</span><span class=\"typ-func\">bytes</span><span class=\"typ-punct\">(</span>hi<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/5f88747ad7a056745bb4d94b9e4440e4.png\" alt=\"Preview\"></div></div>","title":null}}],"self":false,"params":[{"name":"value","details":[{"kind":"html","content":"<p>The value that should be converted to an array.</p>"}],"types":["bytes","array","version"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},"scope":[{"path":["array"],"name":"len","title":"Length","keywords":[],"oneliner":"The number of values in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>The number of values in the array.</p>"}],"self":true,"params":[],"returns":["int"],"scope":[]},{"path":["array"],"name":"first","title":"First","keywords":[],"oneliner":"Returns the first item in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the first item in the array. May be used on the left-hand side\nan assignment. Returns the default value if the array is empty\nor fails with an error is no default value was specified.</p>"}],"self":true,"params":[{"name":"default","details":[{"kind":"html","content":"<p>A default value to return if the array is empty.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"last","title":"Last","keywords":[],"oneliner":"Returns the last item in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the last item in the array. May be used on the left-hand side of\nan assignment. Returns the default value if the array is empty\nor fails with an error is no default value was specified.</p>"}],"self":true,"params":[{"name":"default","details":[{"kind":"html","content":"<p>A default value to return if the array is empty.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"at","title":"At","keywords":[],"oneliner":"Returns the item at the specified index in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the item at the specified index in the array. May be used on the\nleft-hand side of an assignment. Returns the default value if the index\nis out of bounds or fails with an error if no default value was\nspecified.</p>"}],"self":true,"params":[{"name":"index","details":[{"kind":"html","content":"<p>The index at which to retrieve the item. If negative, indexes from\nthe back.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"default","details":[{"kind":"html","content":"<p>A default value to return if the index is out of bounds.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"push","title":"Push","keywords":[],"oneliner":"Adds a value to the end of the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Adds a value to the end of the array.</p>"}],"self":true,"params":[{"name":"value","details":[{"kind":"html","content":"<p>The value to insert at the end of the array.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":[],"scope":[]},{"path":["array"],"name":"pop","title":"Pop","keywords":[],"oneliner":"Removes the last item from the array and returns it.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Removes the last item from the array and returns it. Fails with an error\nif the array is empty.</p>"}],"self":true,"params":[],"returns":["any"],"scope":[]},{"path":["array"],"name":"insert","title":"Insert","keywords":[],"oneliner":"Inserts a value into the array at the specified index, shifting all subsequent elements to the right.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Inserts a value into the array at the specified index, shifting all\nsubsequent elements to the right. Fails with an error if the index is\nout of bounds.</p>\n<p>To replace an element of an array, use <a href=\"/en-US-v0.14.1/reference/foundations/array/#definitions-at\"><code>at</code></a>.</p>"}],"self":true,"params":[{"name":"index","details":[{"kind":"html","content":"<p>The index at which to insert the item. If negative, indexes from\nthe back.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"value","details":[{"kind":"html","content":"<p>The value to insert into the array.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":[],"scope":[]},{"path":["array"],"name":"remove","title":"Remove","keywords":[],"oneliner":"Removes the value at the specified index from the array and return it.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Removes the value at the specified index from the array and return it.</p>"}],"self":true,"params":[{"name":"index","details":[{"kind":"html","content":"<p>The index at which to remove the item. If negative, indexes from\nthe back.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"default","details":[{"kind":"html","content":"<p>A default value to return if the index is out of bounds.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"slice","title":"Slice","keywords":[],"oneliner":"Extracts a subslice of the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Extracts a subslice of the array. Fails with an error if the start or end\nindex is out of bounds.</p>"}],"self":true,"params":[{"name":"start","details":[{"kind":"html","content":"<p>The start index (inclusive). If negative, indexes from the back.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"end","details":[{"kind":"html","content":"<p>The end index (exclusive). If omitted, the whole slice until the end\nof the array is extracted. If negative, indexes from the back.</p>"}],"types":["none","int"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":true,"named":false,"required":false,"variadic":false,"settable":false},{"name":"count","details":[{"kind":"html","content":"<p>The number of items to extract. This is equivalent to passing\n<code>start + count</code> as the <code>end</code> position. Mutually exclusive with <code>end</code>.</p>"}],"types":["int"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"contains","title":"Contains","keywords":[],"oneliner":"Whether the array contains the specified value.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Whether the array contains the specified value.</p>\n<p>This method also has dedicated syntax: You can write <code><span class=\"typ-num\">2</span> <span class=\"typ-key\">in</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span></code>\ninstead of <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">contains</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span></code>.</p>"}],"self":true,"params":[{"name":"value","details":[{"kind":"html","content":"<p>The value to search for.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["bool"],"scope":[]},{"path":["array"],"name":"find","title":"Find","keywords":[],"oneliner":"Searches for an item for which the given function returns `{true}` and returns the first match or `{none}` if there is no match.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Searches for an item for which the given function returns <code><span class=\"typ-key\">true</span></code> and\nreturns the first match or <code><span class=\"typ-key\">none</span></code> if there is no match.</p>"}],"self":true,"params":[{"name":"searcher","details":[{"kind":"html","content":"<p>The function to apply to each item. Must return a boolean.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["any","none"],"scope":[]},{"path":["array"],"name":"position","title":"Position","keywords":[],"oneliner":"Searches for an item for which the given function returns `{true}` and returns the index of the first match or `{none}` if there is no match.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Searches for an item for which the given function returns <code><span class=\"typ-key\">true</span></code> and\nreturns the index of the first match or <code><span class=\"typ-key\">none</span></code> if there is no match.</p>"}],"self":true,"params":[{"name":"searcher","details":[{"kind":"html","content":"<p>The function to apply to each item. Must return a boolean.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["none","int"],"scope":[]},{"path":["array"],"name":"range","title":"Range","keywords":[],"oneliner":"Create an array consisting of a sequence of numbers.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Create an array consisting of a sequence of numbers.</p>\n<p>If you pass just one positional parameter, it is interpreted as the\n<code>end</code> of the range. If you pass two, they describe the <code>start</code> and <code>end</code>\nof the range.</p>\n<p>This function is available both in the array function's scope and\nglobally.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">20</span><span class=\"typ-punct\">,</span> step<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">21</span><span class=\"typ-punct\">,</span> step<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">5</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> step<span class=\"typ-punct\">:</span> <span class=\"typ-op\">-</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/ceb87963d025cafe69d4f502bb2cf46c.png\" alt=\"Preview\"></div></div>","title":null}}],"self":false,"params":[{"name":"start","details":[{"kind":"html","content":"<p>The start of the range (inclusive).</p>"}],"types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">0</span></code>","positional":true,"named":false,"required":false,"variadic":false,"settable":false},{"name":"end","details":[{"kind":"html","content":"<p>The end of the range (exclusive).</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"step","details":[{"kind":"html","content":"<p>The distance between the generated numbers.</p>"}],"types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">1</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"filter","title":"Filter","keywords":[],"oneliner":"Produces a new array with only the items from the original one for which the given function returns true.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Produces a new array with only the items from the original one for which\nthe given function returns true.</p>"}],"self":true,"params":[{"name":"test","details":[{"kind":"html","content":"<p>The function to apply to each item. Must return a boolean.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"map","title":"Map","keywords":[],"oneliner":"Produces a new array in which all items from the original one were transformed with the given function.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Produces a new array in which all items from the original one were\ntransformed with the given function.</p>"}],"self":true,"params":[{"name":"mapper","details":[{"kind":"html","content":"<p>The function to apply to each item.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"enumerate","title":"Enumerate","keywords":[],"oneliner":"Returns a new array with the values alongside their indices.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns a new array with the values alongside their indices.</p>\n<p>The returned array consists of <code>(index, value)</code> pairs in the form of\nlength-2 arrays. These can be <a href=\"/en-US-v0.14.1/reference/scripting/#bindings\">destructured</a> with\na let binding or for loop.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">for</span> <span class=\"typ-punct\">(</span>i<span class=\"typ-punct\">,</span> value<span class=\"typ-punct\">)</span> <span class=\"typ-key\">in</span> <span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;C&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">enumerate</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-punct\">[</span><span class=\"typ-pol\">#</span><span class=\"typ-pol\">i</span>: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">value</span> <span class=\"typ-escape\">\\</span> <span class=\"typ-punct\">]</span>\n<span class=\"typ-punct\">}</span>\n\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;C&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">enumerate</span><span class=\"typ-punct\">(</span>start<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/4bbc8a9ddf0acf4358de76c1f38313a8.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"start","details":[{"kind":"html","content":"<p>The index returned for the first pair of the returned list.</p>"}],"types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">0</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"zip","title":"Zip","keywords":[],"oneliner":"Zips the array with other arrays.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Zips the array with other arrays.</p>\n<p>Returns an array of arrays, where the <code>i</code>th inner array contains all the\n<code>i</code>th elements from each original array.</p>\n<p>If the arrays to be zipped have different lengths, they are zipped up to\nthe last element of the shortest array and all remaining elements are\nignored.</p>\n<p>This function is variadic, meaning that you can zip multiple arrays\ntogether at once: <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">zip</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">10</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">20</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code> yields\n<code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">10</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">20</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code>.</p>"}],"self":true,"params":[{"name":"exact","details":[{"kind":"html","content":"<p>Whether all arrays have to have the same length.\nFor example, <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">zip</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span> exact<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span></code> produces an\nerror.</p>"}],"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"others","details":[{"kind":"html","content":"<p>The arrays to zip with.</p>"}],"types":["array"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"fold","title":"Fold","keywords":[],"oneliner":"Folds all items into a single value using an accumulator function.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Folds all items into a single value using an accumulator function.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> array <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">fold</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">0</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">(</span>acc<span class=\"typ-punct\">,</span> x<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=&gt;</span> acc <span class=\"typ-op\">+</span> x<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/74abb75036c3e00c4b810d4e0d74f915.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"init","details":[{"kind":"html","content":"<p>The initial value to start with.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"folder","details":[{"kind":"html","content":"<p>The folding function. Must have two parameters: One for the\naccumulated value and one for an item.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"sum","title":"Sum","keywords":[],"oneliner":"Sums all items (works for all types that can be added).","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Sums all items (works for all types that can be added).</p>"}],"self":true,"params":[{"name":"default","details":[{"kind":"html","content":"<p>What to return if the array is empty. Must be set if the array can\nbe empty.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"product","title":"Product","keywords":[],"oneliner":"Calculates the product of all items (works for all types that can be multiplied).","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Calculates the product of all items (works for all types that can be\nmultiplied).</p>"}],"self":true,"params":[{"name":"default","details":[{"kind":"html","content":"<p>What to return if the array is empty. Must be set if the array can\nbe empty.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"any","title":"Any","keywords":[],"oneliner":"Whether the given function returns `{true}` for any item in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Whether the given function returns <code><span class=\"typ-key\">true</span></code> for any item in the array.</p>"}],"self":true,"params":[{"name":"test","details":[{"kind":"html","content":"<p>The function to apply to each item. Must return a boolean.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["bool"],"scope":[]},{"path":["array"],"name":"all","title":"All","keywords":[],"oneliner":"Whether the given function returns `{true}` for all items in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Whether the given function returns <code><span class=\"typ-key\">true</span></code> for all items in the array.</p>"}],"self":true,"params":[{"name":"test","details":[{"kind":"html","content":"<p>The function to apply to each item. Must return a boolean.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["bool"],"scope":[]},{"path":["array"],"name":"flatten","title":"Flatten","keywords":[],"oneliner":"Combine all nested arrays into a single flat one.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Combine all nested arrays into a single flat one.</p>"}],"self":true,"params":[],"returns":["array"],"scope":[]},{"path":["array"],"name":"rev","title":"Reverse","keywords":[],"oneliner":"Return a new array with the same items, but in reverse order.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Return a new array with the same items, but in reverse order.</p>"}],"self":true,"params":[],"returns":["array"],"scope":[]},{"path":["array"],"name":"split","title":"Split","keywords":[],"oneliner":"Split the array at occurrences of the specified value.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Split the array at occurrences of the specified value.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">split</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/e0d10d9d30f4e678ab9479679fad56ab.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"at","details":[{"kind":"html","content":"<p>The value to split at.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"join","title":"Join","keywords":[],"oneliner":"Combine all items in the array into one.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Combine all items in the array into one.</p>"}],"self":true,"params":[{"name":"separator","details":[{"kind":"html","content":"<p>A value to insert between each item of the array.</p>"}],"types":["any","none"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":true,"named":false,"required":false,"variadic":false,"settable":false},{"name":"last","details":[{"kind":"html","content":"<p>An alternative separator between the last two items.</p>"}],"types":["any"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"default","details":[{"kind":"html","content":"<p>What to return if the array is empty.</p>"}],"types":["any","none"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["array"],"name":"intersperse","title":"Intersperse","keywords":[],"oneliner":"Returns an array with a copy of the separator value placed between adjacent elements.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns an array with a copy of the separator value placed between\nadjacent elements.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;A&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;B&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;C&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">intersperse</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;-&quot;</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/9ad27cdd1677fc26080cad0c262e0c93.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"separator","details":[{"kind":"html","content":"<p>The value that will be placed between each adjacent element.</p>"}],"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"chunks","title":"Chunks","keywords":[],"oneliner":"Splits an array into non-overlapping chunks, starting at the beginning, ending with a single remainder chunk.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Splits an array into non-overlapping chunks, starting at the beginning,\nending with a single remainder chunk.</p>\n<p>All chunks but the last have <code>chunk-size</code> elements.\nIf <code>exact</code> is set to <code><span class=\"typ-key\">true</span></code>, the remainder is dropped if it\ncontains less than <code>chunk-size</code> elements.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> array <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">6</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">7</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">8</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">chunks</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">chunks</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> exact<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/35c1baf0f7902b3b48cc164333d55b.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"chunk-size","details":[{"kind":"html","content":"<p>How many elements each chunk may at most contain.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"exact","details":[{"kind":"html","content":"<p>Whether to keep the remainder if its size is less than <code>chunk-size</code>.</p>"}],"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"windows","title":"Windows","keywords":[],"oneliner":"Returns sliding windows of `window-size` elements over an array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns sliding windows of <code>window-size</code> elements over an array.</p>\n<p>If the array length is less than <code>window-size</code>, this will return an empty array.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> array <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">6</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">7</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">8</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">windows</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/19a732fa351d05f71c5f8ddfc73c2a3e.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"window-size","details":[{"kind":"html","content":"<p>How many elements each window will contain.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"sorted","title":"Sorted","keywords":[],"oneliner":"Return a sorted version of this array, optionally by a given key function.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Return a sorted version of this array, optionally by a given key\nfunction. The sorting algorithm used is stable.</p>\n<p>Returns an error if two values could not be compared or if the key\nor comparison function (if given) yields an error.</p>\n<p>To sort according to multiple criteria at once, e.g. in case of equality\nbetween some criteria, the key function can return an array. The results\nare in lexicographic order.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> array <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span>\n  <span class=\"typ-punct\">(</span>a<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> b<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">(</span>a<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> b<span class=\"typ-punct\">:</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">(</span>a<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> b<span class=\"typ-punct\">:</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">sorted</span><span class=\"typ-punct\">(</span>key<span class=\"typ-punct\">:</span> it <span class=\"typ-op\">=&gt;</span> <span class=\"typ-punct\">(</span>it<span class=\"typ-punct\">.</span>a<span class=\"typ-punct\">,</span> it<span class=\"typ-punct\">.</span>b<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/fe903cbcc2093647a0fabae43aaaaf52.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"key","details":[{"kind":"html","content":"<p>If given, applies this function to each element in the array to\ndetermine the keys to sort by.</p>"}],"types":["function"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"by","details":[{"kind":"html","content":"<p>If given, uses this function to compare every two elements in the\narray.</p>\n<p>The function will receive two elements in the array for comparison,\nand should return a boolean indicating their order: <code><span class=\"typ-key\">true</span></code>\nindicates that the elements are in order, while <code><span class=\"typ-key\">false</span></code> indicates\nthat they should be swapped. To keep the sort stable, if the two\nelements are equal, the function should return <code><span class=\"typ-key\">true</span></code>.</p>\n<p>If this function does not order the elements properly (e.g., by\nreturning <code><span class=\"typ-key\">false</span></code> for both <code><span class=\"typ-punct\">(</span>x<span class=\"typ-punct\">,</span> y<span class=\"typ-punct\">)</span></code> and <code><span class=\"typ-punct\">(</span>y<span class=\"typ-punct\">,</span> x<span class=\"typ-punct\">)</span></code>, or for\n<code><span class=\"typ-punct\">(</span>x<span class=\"typ-punct\">,</span> x<span class=\"typ-punct\">)</span></code>), the resulting array will be in unspecified order.</p>\n<p>When used together with <code>key</code>, <code>by</code> will be passed the keys instead\nof the elements.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span>\n  <span class=\"typ-str\">&quot;sorted&quot;</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-str\">&quot;by&quot;</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-str\">&quot;decreasing&quot;</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-str\">&quot;length&quot;</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">sorted</span><span class=\"typ-punct\">(</span>\n  key<span class=\"typ-punct\">:</span> s <span class=\"typ-op\">=&gt;</span> s<span class=\"typ-punct\">.</span><span class=\"typ-func\">len</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  by<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>l<span class=\"typ-punct\">,</span> r<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=&gt;</span> l <span class=\"typ-op\">&gt;=</span> r<span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/7dde7fb47ef53c8d8b1aa9991abdf508.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["function"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"dedup","title":"Deduplicate","keywords":[],"oneliner":"Deduplicates all items in the array.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Deduplicates all items in the array.</p>\n<p>Returns a new array with all duplicate items removed. Only the first\nelement of each duplicate is kept.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">dedup</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/eb5537b1ca487f754e0c896313f339ba.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"key","details":[{"kind":"html","content":"<p>If given, applies this function to each element in the array to\ndetermine the keys to deduplicate by.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;apple&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot;banana&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-str\">&quot; apple &quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">dedup</span><span class=\"typ-punct\">(</span>key<span class=\"typ-punct\">:</span> s <span class=\"typ-op\">=&gt;</span> s<span class=\"typ-punct\">.</span><span class=\"typ-func\">trim</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/f407445b261ebb675e8a26021d5f339.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["function"],"strings":[],"default":null,"positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]},{"path":["array"],"name":"to-dict","title":"To Dict","keywords":[],"oneliner":"Converts an array of pairs into a dictionary.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Converts an array of pairs into a dictionary.\nThe first value of each pair is the key, the second the value.</p>\n<p>If the same key occurs multiple times, the last value is selected.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span>\n  <span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;apples&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;peaches&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;apples&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">to-dict</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/2e6b8e445cf77edd022ddf968946479e.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[],"returns":["dictionary"],"scope":[]},{"path":["array"],"name":"reduce","title":"Reduce","keywords":[],"oneliner":"Reduces the elements to a single one, by repeatedly applying a reducing operation.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Reduces the elements to a single one, by repeatedly applying a reducing\noperation.</p>\n<p>If the array is empty, returns <code><span class=\"typ-key\">none</span></code>, otherwise, returns the result\nof the reduction.</p>\n<p>The reducing function is a closure with two arguments: an &quot;accumulator&quot;,\nand an element.</p>\n<p>For arrays with at least one element, this is the same as <a href=\"/en-US-v0.14.1/reference/foundations/array/#definitions-fold\" title=\"`array.fold`\"><code>array.fold</code></a>\nwith the first element of the array as the initial accumulator value,\nfolding every subsequent element into it.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> array <span class=\"typ-op\">=</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">array</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">reduce</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span>acc<span class=\"typ-punct\">,</span> x<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=&gt;</span> calc<span class=\"typ-punct\">.</span><span class=\"typ-func\">max</span><span class=\"typ-punct\">(</span>acc<span class=\"typ-punct\">,</span> x<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/1e6640799dfe1da6d9f5eea2ffbf5c92.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[{"name":"reducer","details":[{"kind":"html","content":"<p>The reducing function. Must have two parameters: One for the\naccumulated value and one for an item.</p>"}],"types":["function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["any"],"scope":[]}]}}}