0
Recursion
To use information from the last operation, I have to use recursion , but I donât understand how to. Iâm trying to modify a nested array, I have to change an element , but donât want to have to do something like âarr[0][0][0][0].changeValue()â
3 Answers
+ 4
That is not how recursion works. Recursion is used when you have a big problem and the solution to it is a smaller problem and this goes on. For eg take the factorial problem, to find 5's factorial you need a 4's factorial and to find a 4's factorial you need a 3's factorial and so on. So I don't think you can use it in your code for nested arrays.
+ 3
Can you give little more detail about what your recursive function need to do ?
If your purpose is to use previous information, then probably there is no need of recursion but if you still want then you can make function with arguments as array(unmodified), index value of element you want to change & new value with return type as array(return modified array & then use it as unmodified array in next call).
+ 1
i actually figured out what i was suppose to do and is similar to what you suggested!