How can I write this simple function in mathematical notation? POINTS_TABLE = [3, 5, 7, 1]

function score(answer) {
  result = 0
  for i in 0..4
    result += POINTS_TABLE[answer[i]]
  return result
}

answer = [1, 2, 1, 0]

s = score(answer)


The sum performed is 5 + 7 + 5 + 3 = 20. It uses the values from the input as the indexes to read from the POINTS_TABLE.

This is the style of the answer I'm trying to work out:
\begin{equation}
score(answer) = \sum_{i=1}POINTS\_TABLE_{answer_i}
\end{equation}
While you are free to use whatever notation you want, as long as you explain it, it seems that the simplest solution here would be


  $$ score(answer) = \sum_{i=0}^3 POINTS\_TABLE[answer[i]] $$


This should be self-explanatory in most circumstances.