<?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>Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?</title><link>https://community.appian.com/discussions/f/general/18728/hi-i-am-new-to-appian-how-to-duplicate-this-java-loop-into-sail-expression</link><description>positionCollect[] = {1,2,3,4,5,6,7,8,9,10}; 
 
 
 for (int i = 0; i &amp;lt; positionCollect.size(); i=i+2) { polygon[i/2] = new Point(positionCollect.get(i), positionCollect.get(i+1)); } 
 
 
 polygon is a Point Class type list, the Point class has two value</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?</title><link>https://community.appian.com/thread/73721?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 16:39:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e12de630-d551-4756-8ca9-4cf55a66de15</guid><dc:creator>peiranl0001</dc:creator><description>&lt;p&gt;Thank you for your answers!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?</title><link>https://community.appian.com/thread/73720?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 16:39:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:257a7dab-a810-4997-a5a4-d6e48c250299</guid><dc:creator>peiranl0001</dc:creator><description>&lt;p&gt;I don&amp;#39;t know how to thank you for your solution! I went through the document but there are no instruction about it!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much! It is works perfertly! Also, do you know what is the best way to learn Expression Rules instead of posting question here? Seems like the document skip over many concept..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?</title><link>https://community.appian.com/thread/73718?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 16:31:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0fe831de-9418-447f-9f11-1cb06d1e5fce</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;You could structure the data differently and as the input provide a &amp;quot;list of lists&amp;quot; - that is a list of pairs of numbers, where each pair represents the x and y values:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!myListOfCoOrdinates: {
    { x: 1, y: 2},
    { x: 3, y: 4},
    { x: 5, y: 6},
    { x: 7, y: 8},
    { x: 9, y: 10}
  },
  a!forEach(
    items: local!myListOfCoOrdinates,
    expression: type!Point(
      x: fv!item.x,
      y: fv!item.y
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;or, indeed, you could leverage Appian&amp;#39;s type casting capability:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!myListOfCoOrdinates: {
    { x: 1, y: 2},
    { x: 3, y: 4},
    { x: 5, y: 6},
    { x: 7, y: 8},
    { x: 9, y: 10}
  },
  cast(
    &amp;#39;type!{urn:com:appian:types:SJB}Point?list&amp;#39;,
    local!myListOfCoOrdinates
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...so many cats, so many ways to skin them!&amp;nbsp;&lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f609.svg" title="Wink"&gt;&amp;#x1f609;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?</title><link>https://community.appian.com/thread/73717?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 16:03:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e56319b1-8389-474f-888e-87149e5adebc</guid><dc:creator>Danny Verb</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
    local!positionCollect: {1,2,3,4,5,6,7,8,9,10},
    local!polygonList: a!forEach(
        enumerate(length(local!positionCollect)/2)+1,
        type!Point(
            x: local!positionCollect[(fv!index*2)-1],
            y: local!positionCollect[(fv!index*2)]
        )
    ),
    local!polygonList
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In Appian all functions and rules will return a value. In the code above, I have a list of positions defined as a list and then a polygonList which calls a!forEach() which will return a list. Also, the code above will only work if your positionCollect list is even.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>