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, {}) ) ) )
Hi Stefan,
I have 2 Questions.
1. There are 2 numbers. one start number and one end number. in between those numbers, we have to find the one number?
example: my start number is 100, end number is 200
find number : 5
output: 105, 115, 125, 135, 145, 150,151,152,153,154,155,156,157,158,159,165,175,185,195
2. my input number is 5
output : 1 22 333 4444
can you pls give the code for these 2 questions?
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)