surma/underdash

An arrange function.

Closed this issue · 0 comments

Pass in a shape (the shape in which the array is to be arranged) and a ?array(optional) , and the array is arranged according to passed shape.

example : arrange([2,3],[1,2,3,4,5,6,7,8]); ==> [[1,2,3],[4,5,6]];

if only shape is passed, random elements are arranged for the given shape.

example : arrange([2,3]) ==> [ [ 0.12321, 0.1243526, 0.865853 ],[ 0.99567, 0.745356236, 0.3252536326 ] ]

example : arrange([6],[[1,2,3],[4,5,6]]) ==> [1,2,3,4,5,6]