I want to define an indexed function $f$ with index $k$ over some arguments $m$. However, I only want to define the index for some set ${1,2,...,x}$ my approach was the following
For[k=1,k<x+1,k++,
f[k,m_]:= g[k,m]
]
Clear[k]
However this seems not to define the function as
In[1]=f[3,n]
yields
Out[1]=g[k,n]
Is there another way to define $f$ as a function of $m$ but with index $k$ on the respective interval?
(Clarification: the original code has $k$ as an index-subscript, but I couldn't find how to do this here)
f[k_, m_] := g[k, m]
(without the loop) then whenever you ask forf[3,n]
you will getg[3,n]
. If you only want it defined for integers, then usef[k_IntegerQ, m_] := g[k, m]
$\endgroup$list
the list of elements{1, 2, ..., x}
(wherex
is given), you can dof[k_Integer, m_] /; MemberQ[list, k] := g[k, m]
, orMemberQ[Range[x], k]
(wherex
is given) if you're only considering a set of consecutive integers up tox
. $\endgroup$