<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Repeat values in an array</title><link>https://community.appian.com/discussions/f/general/21377/repeat-values-in-an-array</link><description>I have an array where I would like to replace the zero values with the previous non-zero value. 
 i.e. convert { 15, 0, 0, 23, 0, 0, 0 } to { 15, 15, 15, 23, 23, 23, 23 } 
 Any ideas?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Repeat values in an array</title><link>https://community.appian.com/thread/83426?ContentTypeID=1</link><pubDate>Wed, 07 Jul 2021 16:21:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:026e33fb-3b0f-44c9-a407-1a9a49406a9f</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Additionally, here&amp;#39;s some sample code that should fit the bill:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!data: {15,0,0,23,0,0,0},
  local!nonZeroIndexes: a!forEach(
    items: local!data,
    expression: if(fv!item=0,null,fv!index)
  ),
  
  a!forEach(
    items: local!data,
    expression: if(
      fv!item&amp;lt;&amp;gt;0,
      fv!item,
      index(
        local!data,
        max(rdrop(local!nonZeroIndexes,count(local!nonZeroIndexes)-fv!index)),
        null
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Repeat values in an array</title><link>https://community.appian.com/thread/83423?ContentTypeID=1</link><pubDate>Wed, 07 Jul 2021 14:38:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:67436f90-6f6b-47e1-9c71-c628c3cc2904</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Pretty much the exact same thing was answered several months ago, &lt;a href="/discussions/f/rules/19286/replace-zero-from-an-integer-array"&gt;here&lt;/a&gt;.&amp;nbsp; The only real difference in that case is the zero values are replaced by the &lt;em&gt;next&lt;/em&gt; nonzero member instead of the &lt;em&gt;previous&lt;/em&gt;, but that should require only a very simple adjustment of the code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>