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
May I ask why you need to do that?
Tried to reduce the lines of code a bit ...
a!localVariables( local!list: floor(rand(23)*100), local!max: 5, a!forEach( items: enumerate(ceiling(length(local!list) / local!max)), expression: a!forEach( items: fv!item * local!max + 1 + enumerate(local!max), expression: index(local!list, fv!item, {}) ) ) )
Nice reduction. And the cost still the same O(n) if not better (depending on the rdrop and ldrop implementations).Awesome.But, why the rand(23)?
Thanks. This is just my self containing example. I think you would turn both locals into rule inputs.
Yeap, put on the code just to everything be visible on the example.