Anyone have a function to create 4D arrays (or any number of dimensions for that matter)?
I’d like to call the function, then after that I can do something like arr[3][2][23][12] = "awesome";
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update: you can specify how deep a level should be in the first parameter, and how many levels in the second. e.g.:
This will allow you to set and get in this format:
But X must always be less than 64. You cannot set
myMultiArray[X][70][X][X]for example, becausemyMultiArray[X][70]has not yet been definedNote- running
make(64, 4)is awfully slow – you are creating 64 ^ 4 empty array elements (i.e. 16,777,216).Update 2: you can get away with the last value as any number or string. Ie.
myMultiArray[X][X][X][Y]where X < 64 and Y can be anything.The algorithm has been optimised as well, give it another go.