I have a function that converts a 1D list to a 3D list, but at the same time, when the indices of the 2nd and 3rd dimensions are equal, it puts zeros instead of the values ββfrom the input list:
n = 4
input = Table[RandomInteger[5], {i, 1, 48}]
convert[l_] := Table[If[i == j, 0, l[[index++]]], {s, 1, 4}, {i, 1, n}, {j, 1, n}]
output = convert[input]
I want to get rid of the Increment [] (++) function.
source
share