input_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Output
l1 [1,5,9,13]
list 2 [2,6,10,14]
llist 3 [3,7,11,15]
l 4 [4,8,12,16]
How to achieve using scala
input_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
l 1 = input_list[0::4]
l 2 = input_list[1::4]
l 3 = input_list[2::4]
l 4 = input_list[3::4]
In python I use this code but in Scala how we done this scale
There's no built-in operator to do this.
One way is to use
zipWithIndexand filter withcollect: