New answers tagged

1

Replace at each position using ReplacePart: pos = Tuples[{Range[row - 1, row + 1], Range[start, start + 2]}] new = ReplacePart[list, pos -> color1] (This produces a new list rather than changing the old one.)


1

In this situation, the most concise way to do what you want that I can think of is: With[{part := Part[list, row - 1 ;; row + 1, start ;; start + 2]}, part = ConstantArray[color1, Most @ Dimensions[part]] ] In short, just create a complete array that matches the dimensions of the Part your trying to overwrite. You're trying to overwrite a part of list ...


Top 50 recent answers are included