How to get particular elements of array

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

Parents Reply
  • 0
    Certified Lead Developer
    in reply to tushark171

    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()
            )
          )
        )
      )
    )

Children