Does Appian (7.11 on-premise) have any easy way in an expression/SAIL to perform

Does Appian (7.11 on-premise) have any easy way in an expression/SAIL to perform the common looping type logic most languages have? Specifically I would like to be able to perform for-next/while/do-until type loops on some other functions and data.
Examples in other languages:
VB: For indexB = 20 To 1 Step -3
C/java: for (i = 0; i < 10; i++)
Fortran: DO I = I_START, I_END, I_INC
A(I) = x+y, etc.
END DO
Basic: FOR cntr = 1 TO 100
total = total + 10
NEXT cntr

I looked through the forums a bit as well as the plugins/expression library and the documentation and I can't find any way to do looping of this type other than via a process model or the somewhat constraining apply(), all(), etc. type functions.

Today I had a need to create a list/array of integers representing years (2012,2013,2014,2015,2016,2017). In most languages I would concatenate values for (myyear = 2012; myyear <= 2017;...

OriginalPostID-188844

OriginalPostID-188844

  Discussion posts and replies are publicly visible

  • ... myyear++) {concatenate(myyear)}
    or some such type of logic to make a list. Instead I had to use some funky logic using the apply(fn!sum,2012,enumerate(6)) type of logic and it was tedious to try and come up with the logic, here is part of it:
    List of years using the number of years before/after current year:

    apply(fn!cast(typeof(123),_),{union(reverse(apply(fn!sum(year(local(now())),_),-1*enumerate(ri!YearsBeforeCurrent+1))),
    apply(fn!sum(year(local(now())),_),enumerate(ri!YearsAfterCurrent+1)))})

    returned value: 2014; 2015; 2016; 2017

    I am happy to supply a better example/screen shots if needed.
  • 0
    Certified Lead Developer
    Not really an answer for your common loops question but for your issue this snippet should work and remove the funky logic: "year(now()) +/- enumerate(n)". There is a gotcha with this code: n=0 and n=1 produce the same output.
  • 0
    Certified Lead Developer
    Also instead of using apply(cast(typeof(1), _), {list}) you can use this syntax: cast(typeof({1}), {list)
  • Josh, thanks for the suggestion on the change on the cast() function, I'll take a look at it. As for your year() reference, yes, I was having to do something like that. A coworker had made a Java based plugin to calculate company holidays using some preexisting logic another department had built. A second coworker had built a rule in Appian that would take an individual year and spit out the holidays for a few years before & after that years. It used concatenation inside of the rule and I wanted to see if I could rewrite it to allow you to pass in 2 integers for the number of years before & after the current and get the same results. (I didn't test with 0 as you did, thanks). Here is what my replacement looked like, white convoluted:

    apply(fn!commerceobservedholidaysforagivenyear,
    apply(fn!cast(typeof(123),_),{union(reverse(apply(fn!sum(year(local(now())),_),-1*enumerate(ri!YearsBeforeCurrent+1))),
    apply(fn!sum(year(local(now())),_),enumerate(ri!YearsAfterCurrent+1)))}) )

    returned value: 1/1/2014; 1/20/2014; 2/17/2014; 5/26/2014; 7/4/2014; 9/1/2014; 10/13/2014; 11/11/2014; 11/27/2014; 12/25/2014; 1/1/2015; 1/19/2015; 2/16/2015; 5/25/2015; 7/4/2015; 9/7/2015; 10/12/2015; 11/11/2015; 11/26/2015; 12/25/2015; 1/1/2016; 1/18/2016; 2/15/2016; 5/30/2016; 7/4/2016; 9/5/2016; 10/10/2016; 11/11/2016; 11/24/2016; 12/26/2016; 1/2/2017; 1/16/2017; 2/20/2017; 5/29/2017; 7/4/2017; 9/4/2017; 10/9/2017; 11/11/2017; 11/23/2017; 12/25/2017