<?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>Getting Indices from an Array of Number</title><link>https://community.appian.com/discussions/f/rules/34056/getting-indices-from-an-array-of-number</link><description>Hi, 
 We have an expression rule (see below image). We want to get the indices of numbers from the array (local!numberList) that would not make the local!initialValue negative when added together. 
 
 The result we are expecting from the sample values</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129586?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 11:02:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1737a69d-882e-4b5e-808a-fb1793bd45b2</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;Thank you for sharing this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129575?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 09:54:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bef9cc03-b3c7-4156-ad87-1ec2b8625050</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;Woah, I didn&amp;#39;t know this. Thank you so much!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129563?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 08:57:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d625e5e5-7625-4219-aee5-fe343a12dcc3</guid><dc:creator>nasirs4970</dc:creator><description>&lt;p&gt;Code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!a:100,
  local!array:{5,100,15,100,25},
  reject(
    fn!isnull,
    a!forEach(
    items: local!array,
    expression: a!localVariables(
      local!Boolean:if(
        fv!isFirst,
        {fv!item&amp;lt;100},
        a!forEach(
          items: enumerate(fv!index-1)+1,
          expression: local!a-sum(index(local!array,enumerate(fv!item)+1,0))&amp;gt;0
        )
      ),
      local!currentItem:fv!item,
      local!BooleanSum:if(
        fv!isFirst,
        0,
        sum(a!forEach(
        items: local!Boolean,
        expression: if(
          fv!item,
          index(local!array,fv!index,{}),
          0
        )
      ))
      ),
      if(
        local!a-sum(local!BooleanSum,local!currentItem)&amp;gt;0,
        fv!index,
        null()
      )
    )
  )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;result&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1707987413577v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129561?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 08:43:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e3644fee-b668-4fe7-a3e4-3d89ae8610d9</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I think this calls for a recursive approach. I wrote a blog post about implementing algorithms in Appian.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://appian.rocks/2022/08/29/complex-algorithms-in-appian/"&gt;https://appian.rocks/2022/08/29/complex-algorithms-in-appian/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129558?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 08:15:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fa6d5435-5a86-406d-aad0-913eb365388c</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;Test Case 1: {1, 2, 5}&lt;/p&gt;
&lt;p&gt;Test Case 2: {1, 2, 4}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129546?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 06:54:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c4b5b023-1e94-41b3-98ae-8a23e2bf7fff</guid><dc:creator>Harshmodi</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;Could you please provide me the output of these test cases to enhance my understanding?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Initial Value: 100 for both cases.&lt;/p&gt;
&lt;p&gt;Test Case 1:&lt;/p&gt;
&lt;p&gt;[10, 5,100, 90, 25]&lt;/p&gt;
&lt;p&gt;Test Case 2:&lt;/p&gt;
&lt;p&gt;[5, 5, 100, 90, 10]&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129545?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 06:01:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5ecdefe0-f195-4866-a26d-062524280887</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;For the 5th iteration, we want the 4th item to be removed from the list to add, since having it would make the initial value negative. So for 5th iteration the value of sum should be 55 - the summation of indices 1, 2, 3,and 5 excluding 4.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129542?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 05:57:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f8f43b5d-9861-4ab4-b79c-6ac18d4682af</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;But for iteration 4, the sum would be 130. So 100 - 130 would make the local!initialValue negative.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129540?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 05:55:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8a6bdb8f-af8d-4ee1-bd4b-a17a1ef05836</guid><dc:creator>Dabs Medina</dc:creator><description>&lt;p&gt;Let&amp;#39;s say for iteration 3, we are indexing item 1, 2, and 3 from the local!numberList, which value is {5, 10, 15, 100, 25}, so the value&amp;nbsp;that the sum() function would return in this iteration is 30. 100 - 30 = 70, so in this case the index should be returned.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1707976329100v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting Indices from an Array of Number</title><link>https://community.appian.com/thread/129539?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 05:50:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:16c0dcd6-ca3f-4ecc-a7eb-d02fe48b0268</guid><dc:creator>Boddupalli Bhargav</dc:creator><description>&lt;p&gt;Can you ellobrate what does added together means?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>