Amateur here! I made a short piece of code that creates a line that turns in the positive direction (up or to the right) if the sum of the digits of the outcome of a function (x^2 in this case) is even, or else it moves in the negative direction.
QUESTION: How can I avoid the use of so many variables (l1 to l5) while maintaining clarity of code?
Especially I feel that doing MapAt twice (for even and odd items) can be done more efficiently.
f[x_] := x^2 length = 600; L1 = If[EvenQ[#], 1, -1] & /@ Total[IntegerDigits[f[Range[0, length]]], {2}]; L2 = MapAt[{#, 0} &, L1, 1 ;; ;; 2]; L3 = MapAt[{0, #} &, L2, 2 ;; ;; 2]; L4 = Table[Sum[L3[[i]], {i, 1, j}], {j, 1, length + 1}]; L5 = PrependTo[L4, {0, 0}]; Graphics[Line[L5]] 




las first letter in your variables? They look like1and makes it hard to read. You can useL1for example instead ofl1$\endgroup$AnglePathdocumentation. $\endgroup$