<?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>Replace zero from an Integer array</title><link>https://community.appian.com/discussions/f/rules/19286/replace-zero-from-an-integer-array</link><description>Hi All, 
 I need to replace zero with next value in array. 
 ex: {1,2,3,0,0,10,15,0,14,0} ; then result should be {1,2,3,10,10,10,15,14,14,0} 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Replace zero from an Integer array</title><link>https://community.appian.com/thread/75491?ContentTypeID=1</link><pubDate>Tue, 21 Jul 2020 14:46:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3b776633-3486-4cee-86d9-2daf86a210f0</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Out of curiosity, why not use something more simple like, &amp;quot;&lt;strong&gt;if(fv!item = 0, index(local!values, fv!index+1, 0), fv!item)&lt;/strong&gt;&amp;quot;?&amp;nbsp; Granted, I haven&amp;#39;t tested either way, just my quick-glance impression.&amp;nbsp; I don&amp;#39;t immediately see why we need to involve &lt;em&gt;ldrop()&lt;/em&gt;, for example.&lt;/p&gt;
&lt;p&gt;Edit: i missed the requirement that if the next value is zero then it should forward-seek until it finds the first nonzero value.&amp;nbsp; I&amp;#39;ll just go ahead and retract my objection ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Replace zero from an Integer array</title><link>https://community.appian.com/thread/75489?ContentTypeID=1</link><pubDate>Tue, 21 Jul 2020 13:38:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ecccff65-202e-42bf-aaea-d5b7cd4884a1</guid><dc:creator>shilpas0003</dc:creator><description>&lt;p&gt;Thank you Stefan!&lt;/p&gt;
&lt;p&gt;This is a part of business requirement where we need to replace 0 with next amount value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Replace zero from an Integer array</title><link>https://community.appian.com/thread/75488?ContentTypeID=1</link><pubDate>Tue, 21 Jul 2020 13:18:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e4bdb1ff-d4b0-4766-bd85-043f866a2e0f</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!values: {1,2,3,0,0,10,15,0,14,0},
  a!forEach(
    items: local!values,
    expression: if(
      fv!item = 0,
      index(
        /* Only take values after the current one */
        ldrop(local!values, fv!index - 1),
        /* Find the first not being zero */
        /* where() evaluates zero as false and &amp;gt;0 as true */
        index(where(ldrop(local!values, fv!index - 1)), 1, 0),
        fv!item
      ),
      fv!item
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This should do it. May I ask what the use case is?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>