Hello,
I have a array of integer [1,2,3,4,5,6,7,8,9,10,11] is there any function which will give me elements of array if I pass index.
or what's the way to get batches of array in particular set.
e.g. [123],[456],[789],[10,11]
thanks,
Tushar
Discussion posts and replies are publicly visible
You will probably find it easiest to use a looping process model, where each time a loop finishes, you remove the members of the array that you've already processed. Each time a loop begins you can get the first X number of indices from the current array pretty easily - if it's 100, you would do:
index( pv!array, enumerate(100)+1, {})
Additionally - I was just able to whip up the following which breaks up any given input array into sub-array chunks of any given size. You might be able to use it to some effect for your use case, after a bit of tweaking.
with( local!chunkSize: 3, /* configurable */ local!startingList: { "a", "b", "c", "d", "e", "f", "g", "h" }, local!wholeListSize: rule!APN_arrayLength(local!startingList), local!numChunks: ceiling(local!wholeListSize / local!chunkSize), a!forEach( enumerate(local!numChunks), with( local!currentStartIndex: fv!item * local!chunkSize + 1, /* note: this utilizes zero-index of fv!item */ local!currentIndices: enumerate(local!chunkSize) + local!currentStartIndex, rule!GLBL_removeBlankArrayMembers( /* this rule just unions the input array with itself */ index( local!startingList, local!currentIndices, null() ) ) ) ) )