How to run math action/function from a list in a specific order at any called time, one by one
<p>I'm trying to build an algorithm in java, which in ugly way looks like this:</p>

<pre><code>while (true) {
    Point p; //a point given in the class constuctor.
    p.x+=1*factor;
    checkColor(p); // a function that returns true or false for a pixel color.
    p.y+=1*factor;
    checkColor(p);
    p.x-=2*factor;
    checkColor(p);
    p.y-=*factor;
    ... ...
}
</code></pre>

<p>This will use a int factor; that will increase every cycle in the loop,
but my point is if there is a way to store a 'line of actions' that will be executed 1 line at a time, when I call a a function.</p>
