# Defining function from table [closed]

I have a table of values of the form

Table[{i1,j1}, {i2,j2}...]


and I want to define a function like f[i] to take the values from the table, i.e. f[i2] = [j2] and so on. Can I do this in Mathematica?

• You want to use Interpolation – Jason B. Oct 5 '15 at 11:28
• You could do either this f = <|Sequence @@ Rule @@@ Table[{x[i], y[i]}, {i, n}]|> or Map[f[#[[1]]] = #[[2]] &, Table[{x[i], y[i]}, {i, n}]];. – Coolwater Oct 5 '15 at 11:28
• It is not clear what is your Table[...]. Is it the way your create your list of pairs ? Give a more precise example. – SquareOne Oct 5 '15 at 11:34
• f[i2]=[j2] means nothing. You did not correct your question and already accepted the first answer. I am voting to close. – SquareOne Oct 5 '15 at 12:03

table = Table[{ToExpression["i" <> ToString@n], ToExpression["j" <> ToString@n]}, {n, 5}]

$\${{i1, j1}, {i2, j2}, {i3, j3}, {i4, j4}, {i5, j5}}
(f[#1] = #2) & @@@ table

$\${j1, j2, j3, j4, j5}
?f