Suggestions on how to avoid copying and pasting code

In working with a table recently, I needed to copy and paste code in a fairly predictable and error-prone fashion. The code for the first two rows is shown below; I end up copying to a text editor to find and replace, then hope I don’t miss anything…

Is there any way of avoiding this type of coding? (And/or something in the works so we could potentially have loops/macros to reduce it?)

point_1 = this.cellContent(1, 2)
student_1 = this.cellContent(1, 3)

image_1_x = x_fn.evaluateAt(numericValue(parseOrderedPair(point_1).x))
image_1_y = y_fn.evaluateAt(numericValue(parseOrderedPair(point_1).y))
student_1_x = numericValue(parseOrderedPair(student_1).x)
student_1_y = numericValue(parseOrderedPair(student_1).y)
correct_1 = image_1_x = student_1_x and image_1_y = student_1_y

point_2 = this.cellContent(2, 2)
student_2 = this.cellContent(2, 3)

image_2_x = x_fn.evaluateAt(numericValue(parseOrderedPair(point_2).x))
image_2_y = y_fn.evaluateAt(numericValue(parseOrderedPair(point_2).y))
student_2_x = numericValue(parseOrderedPair(student_2).x)
student_2_y = numericValue(parseOrderedPair(student_2).y)
correct_2 = image_2_x = student_2_x and image_2_y = student_2_y
1 Like