With all due respect, I’m guessing you don’t work with a lot of multi-dimensional data. Most of our stuff is done in Matlab and we are frequently working with datasets that have five or more dimensions. Nothing wrong with writing this:
for i = 1:n_i
for j = 1:n_j
for k = 1:n_k
for m = 1:n_m
do_some_function( my_mega_matrix{i,j,k,m} );
end
end
end
end
There’s not much of a cleaner way to write it in cases like this. If you bury some of that in a sub-function, the semantics don’t really make sense and it adds lines of code unnecessarily. And before you ask, this would be for something that can’t be vectorized.
View all comments
Show parent comment
1
u/MattTheGr8 Jun 09 '20
With all due respect, I’m guessing you don’t work with a lot of multi-dimensional data. Most of our stuff is done in Matlab and we are frequently working with datasets that have five or more dimensions. Nothing wrong with writing this:
There’s not much of a cleaner way to write it in cases like this. If you bury some of that in a sub-function, the semantics don’t really make sense and it adds lines of code unnecessarily. And before you ask, this would be for something that can’t be vectorized.