Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
4 replies
Subscribers
7 subscribers
Views
8099 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Array Functions
kalpanap
over 8 years ago
Hi All,
I have a requirement where there is a count eg. 12 containing {1,2,3,4,5,6,7,8,9,10,11,12} , from which i need to take out 3 lists like listA: {1,4,7,10}, listB: {2,5,8,11} and listC: {3,6,9,12} with uniform interval of 4. How can I achieve this in looping . You suggestion is appreciated.. Thanks
OriginalPostID-254666
Discussion posts and replies are publicly visible
0
chetany
A Score Level 1
over 8 years ago
Here's one solution:
with(
local!arrayLength: length(ri!array),
local!listA: wherecontains(todecimal(0), mod(3+enumerate(local!arrayLength), ri!interval )) ,
local!listB: wherecontains(todecimal(0), mod(2+enumerate(local!arrayLength), ri!interval)) ,
local!listC: wherecontains(todecimal(0), mod(1+enumerate(local!arrayLength), ri!interval )),
{
local!listA,
local!listB,
local!listC
}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
TJ
A Score Level 2
over 8 years ago
In case you need a generalized answer with more iterations- you can use following code:
Rule 1:
load(
local!itemCount:fn!count(ri!list),
local!minItemPerSubList:local!itemCount/ri!subListsCount,
fn!apply(
rule!getList(list:ri!list,subListsCount: ri!subListsCount,
iteration:_,itemsPerSubList: local!minItemPerSubList),
fn!enumerate(ri!subListsCount)+1
)
)
Rule: getList:
fn!index(ri!list,{fn!enumerate(ri!itemsPerSubList)+((ri!iteration-1)*ri!itemsPerSubList)+1},{})
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kalpanap
over 8 years ago
Thanks for your suggestions. But the examples show the row separation. But as per my requirement, i need column wise as I have given. another example is list: {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18} :- 2 rows data so i require 9 lists holding : - listA: {1,10}, listB: {2,11}, listC: {3,12} etc.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kalpanap
over 8 years ago
I have modified the column items... Thanks a lot
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel