I have a list $\{a,b,c,d,e,f\}$ and an array of variables $\{y[1],y[2],y[3],y[4],y[5],y[6]\}$. I want to use the RuleDelayed function represented by the symbol :> to replace the variables with the elements on the list $\{a,b,c,d,e,f\}$. The code is written as,
list={a,b,c,d,e,f}; array=Array[y, 6]; array/.y[i_] :> list[[i]] However, I want the RuleDelayed function :> to replace $\{y[2],y[3],y[4],y[5]\}$ with $b,c,d,e$ excluding the first and last terms so that I have {y[2]:>b,y[3]:>c,y[4]:>d,y[5]:>e}, i.e., the function y[i_] starts from i=2 and ends at i=5. The question is, how should I modify the function y[i_] :> list[[i]] so that the index starts at i=2 and ends at i=5?
Please do not respond by saying that I should just generate an array from y[2] to y[5]. I asked this question while using RuleDelayed to understand how to modify the function y[i_].
list = {b, c, d, e}; array /. y[i_ /; 1 < i < 6] :> list[[i - 1]]$\endgroup$y[i_]", does this mean you actually want to set DownValues for y? I.e. you want to end up with definitions likey[2]=aand so forth? $\endgroup$arrayandlistdo you want the rule to always be "centered"? $\endgroup$list[[2]]would givec, rather thanb, as it seems to be implied by OP. Unless, of course, the second list example is being compared with the first, in some way? This needs more information, to be sure. $\endgroup$DownValues? I guess not. Yes, I want it for arbitrary sized list and basically, if you give me a list of lengthn. I want to replace{y[2], ..., y[n-1]}with it, i.e., the array ofystarts ati=2and ends ati=n-1. However, I want to do this usingRuleDelayed. $\endgroup$