I'm trying to create a certain "excel-like" recursive function, which runs through a pre-defined list and performs an operation dependent upon the current position (similar to the "drag down" type functionality of Excel). Here is some example code, where "m" is the list:
alt[x_] := If[Mod[x, 4] == 3 || Mod[x, 4] == 1, 0, If[Mod[x, 4] == 2, 1, -1]]
ex[x_] := ex[x] = ex[x - 1] + alt[x]*m[[x]]
ex[1] = 0
(* 0 *)
$RecursionLimit = Infinity
(* ∞ *)
ex[10000]
However when evaluating at a large point, the program quits the calculation without an error. Thanks so much for any advice!
list1 = {1, 2, 3, 4, 5}
and you want to multiply each by 2, you can easily do that with2*list1
. If what you're doing depends on the position in the list, try something likeTable[list1[[i]] * i, {i, 1, Length[list1]}
(this outputs{1, 4, 9, 16, 25}
), where i becomes the position in the list. $\endgroup$