Your task is to write a program which given an array and a number, you need to split the array into chunks with size is number.
Your program will receive an array
A , as well as a positive integer
n. The array should then be split into chunks of length
n, if the length of the string isn't divisible by
n any leftover at the end should be considered its own chunk.
nis greater than length of array
A, you will need to return array
A, for example: if
n = 4and
array A = [1,2,3], you should return
The array can contain any type rather than number.
You should not change order (or direction) of any item from left to right. For example
if n = 2and
A= [1,2,3]. Any result rather than
[[1,2],]will be invalid.
n A Output 2 [1,2,3,4,5,6] [[1,2],[3,4],[5,6]] 3 [1,2,3,4,5,6] [[1,2,3],[4,5,6]] 4 [1,2,3,4,5,6] [[1,2,3,4],[5,6]]
This is code-golf, so you the shortest bytes of each language will be the winner.