<?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>apply Function Issue</title><link>https://community.appian.com/discussions/f/user-interface/17245/apply-function-issue</link><description>I have a gridtextColumn with a local variable to store the datasubset value obtained from a query. I am trying to build a link to a record for that column on all rows of the grid. I used apply function with a proper rule and index function along with</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147971?ContentTypeID=1</link><pubDate>Sat, 10 May 2025 14:54:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ea5bcaac-405f-4af5-9879-4e55241173d2</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;&lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f440.svg" title="Eyes"&gt;&amp;#x1f440;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147964?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 17:27:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b75fc0bf-7aa2-465d-bcb0-86884b5d80d4</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I did my own little stress test - it looks like in extreme cases (lists of 100,000 items for example), apply() is between 6x and 10x faster than a!forEach().&amp;nbsp; Probably because apply() is a primitive function and, i&amp;#39;d guess, uses lower-level code.&amp;nbsp; IMHO this trade-off would only matter in ridiculously extreme cases and very very rarely matter in any real-world usage, particularly compared to the complexity and readability trade-off.&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/13/pastedimage1746811616494v1.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1746811620981v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147963?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 17:25:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7d4da404-b2d1-4f08-97ea-d72e912eb4dc</guid><dc:creator>sanjuktab2257</dc:creator><description>&lt;p&gt;I just did a stress test, a!apply took 4ms where as a!forEach took 21ms&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/13/pastedimage1746811514898v1.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147962?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 17:20:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:10a8f070-a018-4cdd-8090-69546d48b7c9</guid><dc:creator>sanjuktab2257</dc:creator><description>&lt;p&gt;Thanks Mike!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147961?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 17:18:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:197a7764-35ec-4e7f-92ac-5df6f6bcb9d5</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="289109" url="~/discussions/f/user-interface/17245/apply-function-issue/147959"]Is the time complexity of a!apply and a!forEach is same? [/quote]
&lt;p&gt;If you just mean execution time, I&amp;#39;ve never heard any reputable evidence that a!forEach() is any measurable amount slower than apply(), even in stress tests.&amp;nbsp; But you could always devise your own stress test and compare, I guess.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/147959?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 16:40:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:842747ac-bff4-4480-8b06-0b198739c32b</guid><dc:creator>sanjuktab2257</dc:creator><description>&lt;p&gt;Is the time complexity of a!apply and a!forEach is same? or apply is like map function in appian with time complexity O(1)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/68020?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 13:59:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d9ac57ff-75f1-4fd3-b8bd-1cebaab7f1d6</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;That&amp;#39;s exactly right, Mike.&amp;nbsp; If you include the parentheses, you also have to use partial evaluation to show the code where the array of items are supposed to be input as parameters one at a time.&lt;/p&gt;
&lt;p&gt;apply(&lt;/p&gt;
&lt;p&gt;rule!myRule,&lt;/p&gt;
&lt;p&gt;local!myList&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;does the same thing as&lt;/p&gt;
&lt;p&gt;apply(&lt;/p&gt;
&lt;p&gt;rule!myRule(_),&lt;/p&gt;
&lt;p&gt;local!myList&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;You need the underscore, otherwise you make it look like you&amp;#39;re applying a rule with no parameters to a list, which doesn&amp;#39;t make any sense.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/67985?ContentTypeID=1</link><pubDate>Sat, 06 Jul 2019 03:25:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:926fd6d7-c6f3-4ba8-93df-784187c5d069</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Cool - a!forEach is generally more flexible as well as more powerful while still being easier to understand overall.&lt;/p&gt;
&lt;p&gt;As far as why your original code didn&amp;#39;t work - my first guess is that when you reference a rule with apply() without specifying parameters, you need to invoke the rule name without the () at the end.&amp;nbsp; so more like this:&lt;/p&gt;
&lt;p&gt;apply(&lt;br /&gt;&amp;nbsp; rule!myRule,&lt;br /&gt;&amp;nbsp; local!myList&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/67984?ContentTypeID=1</link><pubDate>Sat, 06 Jul 2019 02:42:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4f432eea-4255-4e60-925a-e4636add73df</guid><dc:creator>aneeshv713</dc:creator><description>&lt;p&gt;a!forEach() worked. Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/67983?ContentTypeID=1</link><pubDate>Sat, 06 Jul 2019 02:37:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f6ef9be9-e9c3-437d-9f8d-f4d2d3ade7d4</guid><dc:creator>aneeshv713</dc:creator><description>&lt;p&gt;No particular reason.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: apply Function Issue</title><link>https://community.appian.com/thread/67980?ContentTypeID=1</link><pubDate>Sat, 06 Jul 2019 00:56:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:accd21a6-ea41-4585-92bd-3feb96d9821f</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Is there any particular reason you&amp;#39;re still using apply() instead of a!forEach()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>