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
Here is the answer for 1 Question :-
a!localVariables( local!xyz: 101 + enumerate(100), local!where_five: a!forEach( items: local!xyz, expression: like(tostring(fv!item), "*5*") ), index( local!xyz, wherecontains(true, local!where_five), {} ) )
Q2.
a!forEach( enumerate(5), substitute( tostring( repeat(fv!index,fv!item) ), "; ", "" ) )
1)
a!localVariables( local!xyz: 101 + enumerate(100), index( local!xyz, where(like(touniformstring(local!xyz), "*5*")) ) )
2)
a!forEach( items: enumerate(5), expression: rept(fv!item, fv!item) )
just an alternate approach for 1)
a!localVariables( local!num: 101 + enumerate(100), reject( fn!isnull, if(mod(local!num, 5) = 0, local!num, {}) ))
for 2) i think we dont need to loop:
rept(enumerate(5)+1, enumerate(5) + 1)
This works fine with just a single forEach().
a!forEach( items: touniformstring(enumerate(200-100+1) + 100), expression: if( find("5",fv!item), fv!item,{} ) )
a!forEach( items: enumerate(5), expression: repeat(fv!item,fv!item) )