2
$\begingroup$

I have a fixed list where I want to add another list with multiple passes. What would be a proper function for this?

list1 = {2, 3}; addList = {4, 3}; numSteps = 5;
l2 = list1 + addList;
l3 = % + addList;
l4 = l3 + addList;
l5 = l4 + addList;
l6 = l5 + addList;
{list1, l2, l3, l4, l5, l6}

({{2, 3}, {6, 6}, {10, 9}, {14, 12}, {18, 15}, {22, 18}})

$\endgroup$
  • 2
    $\begingroup$ Table[{2, 3} + k {4, 3}, {k, 0, 5}]? $\endgroup$ – J. M. is away Oct 6 '16 at 14:52
  • 1
    $\begingroup$ Array[{2, 3} + {4, 3} (# - 1) &, 6] $\endgroup$ – BlacKow Oct 6 '16 at 15:15
3
$\begingroup$

You can get this way:

list1 = {2, 3}; addList = {4, 3}; numSteps = 5;
positions = NestList[addList + # &, list1, numSteps]
points = {Red, PointSize[0.02], Point[positions]};
Graphics[{points}, Axes -> True, AspectRatio -> 20/25, 
 PlotRange -> {{25, 0}, {0, 20}}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.