I start with an array such as
I want to create an array from this which replaces each array inside the array with 3 new arrays, one prepended with 1, one prepended with 0 and one prepended with -1. For example, applying this to the above array would give:
I need to find an efficient method to apply this multiple times to an array (i.e. the same algorithm would then be applied to (2) yielding a list containing 27 lists and so on).
I have tried using For loops but cannot get them to work and I suspect they would be very slow.
Ideally I would also like to be able to specify how many times to apply this algorithm.