<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Slice &amp;quot;step&amp;quot; possible with Arcade? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/slice-quot-step-quot-possible-with-arcade/m-p/1479894#M7063</link>
    <description>&lt;P&gt;If you throw that loop into a function, it's &lt;EM&gt;technically&lt;/EM&gt; a one-liner when you actually execute it? Not great, though.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var myString = "Examples"

function Step(arr, step) {
  var out_array = []
  for (var a in arr) {
    if (a % step == 0) {
      Push(out_array, arr[a])
    }
  }
  return out_array
}

return Concatenate(Step(Slice(Split(myString, ""), 0, 6), 2))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1716938988467.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105589iB31B2AFF3BD82D65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1716938988467.png" alt="jcarlson_0-1716938988467.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 23:31:36 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2024-05-28T23:31:36Z</dc:date>
    <item>
      <title>Slice "step" possible with Arcade?</title>
      <link>https://community.esri.com/t5/developers-questions/slice-quot-step-quot-possible-with-arcade/m-p/1479870#M7062</link>
      <description>&lt;P&gt;With python, I can slice an array or string using brackets and a colon. And using the optional "step" parameter I can get every second (or third, fourth, etc) array item. I just add a second colon followed by the number 2 (or 3, or 4, etc). For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#slicing with python
myString =  "Examples"
myString[0:6] #returns "Exampl"
myString[0:6:2] #returns "Eap"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With arcade, I know how to perform a basic string slice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//slicing with Arcade
var myString = "Examples"
Concatenate(Slice(Split(myString,""), 0, 6)) //returns "Exampl"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to get every second letter with Arcade, like the python step parameter does. At least not in a single line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var myString = "Examples"
//i know the below won't work, but is something like this possible?
Concatenate(Filter(Slice(Split(myString,""), 0, 6), index % 2 == 0)) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I could set up a for loop to get the desired result, but I'm curious if it can be achieved in a single line without a For loop. Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 22:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/slice-quot-step-quot-possible-with-arcade/m-p/1479870#M7062</guid>
      <dc:creator>ColeSutton</dc:creator>
      <dc:date>2024-05-28T22:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Slice "step" possible with Arcade?</title>
      <link>https://community.esri.com/t5/developers-questions/slice-quot-step-quot-possible-with-arcade/m-p/1479894#M7063</link>
      <description>&lt;P&gt;If you throw that loop into a function, it's &lt;EM&gt;technically&lt;/EM&gt; a one-liner when you actually execute it? Not great, though.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var myString = "Examples"

function Step(arr, step) {
  var out_array = []
  for (var a in arr) {
    if (a % step == 0) {
      Push(out_array, arr[a])
    }
  }
  return out_array
}

return Concatenate(Step(Slice(Split(myString, ""), 0, 6), 2))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1716938988467.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105589iB31B2AFF3BD82D65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1716938988467.png" alt="jcarlson_0-1716938988467.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 23:31:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/slice-quot-step-quot-possible-with-arcade/m-p/1479894#M7063</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-28T23:31:36Z</dc:date>
    </item>
  </channel>
</rss>

