# How can I write this simple function in mathematical notation?

POINTS_TABLE = [3, 5, 7, 1]

result = 0
for i in 0..4
return result
}

answer = [1, 2, 1, 0]



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}

• I don't really understand. What's wrong with the expression you already have? "Mathematical notation" isn't a programming langauge with defined syntax and semantics; it's much more like a natural language and there are multiple ways of writing things. Some may be more or less appropriate, depending on what you want to use the notation for. – David Richerby Jan 14 '17 at 22:24
• Oh, I thought math notation was strict. The expression I have was my best attempt, I assumed it was wrong. – Qgenerator Jan 14 '17 at 22:28
• So do mathematicians reading the notation it have to interpret it and try to guess what's meant? – Qgenerator Jan 14 '17 at 22:29
• No, the author of the paper should explain all non-standard notation. – Yuval Filmus Jan 14 '17 at 22:34
• However did you get the idea that this was a functional program? O.o – Raphael Jan 14 '17 at 22:34

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