Splitting an array

Hi All, 

Need some help with writing a logic.

I have an integer array {1,2,3,4,5,6,7,8,9,10,11,12}.

I want an output as three arrays {1,2,3,4,5},  {6,7,8,9,10},  {11,12}

Any function or quick work around to split an array by grouping first five elements in an array, next five elements in array and so on

TIA

Arun

  Discussion posts and replies are publicly visible

Parents
  • hi just to extend on this question which I need to clarify:

    for this sample array: 

    local!list: {
    {
    id: 1,
    text: "first text",
    name: "Ada"
    },
    {
    id: 2,
    text: "2nd text",
    name: "ben"
    },
    {
    id: 3,
    text: "3rd text",
    name: "sam"
    }
    },

    what is the best way to separate the array into sub arrays, using a specific index eg. 2 then I should only get 

    local!newList: {{
    id: 1,
    text: "first text",
    name: "Ada"
    },
    {
    id: 2,
    text: "2nd text",
    name: "ben"
    }}

Reply
  • hi just to extend on this question which I need to clarify:

    for this sample array: 

    local!list: {
    {
    id: 1,
    text: "first text",
    name: "Ada"
    },
    {
    id: 2,
    text: "2nd text",
    name: "ben"
    },
    {
    id: 3,
    text: "3rd text",
    name: "sam"
    }
    },

    what is the best way to separate the array into sub arrays, using a specific index eg. 2 then I should only get 

    local!newList: {{
    id: 1,
    text: "first text",
    name: "Ada"
    },
    {
    id: 2,
    text: "2nd text",
    name: "ben"
    }}

Children