title: How elegantly to call methods with various order?
body: <p>I have four methods:</p>
  
  <pre><code>right();
  up();
  left();
  down();
  </code></pre>
  
  <p>Then I call them in the following fashion:</p>
  
  <pre><code>result = right();
  if checkResult(result)
    return(result);
  
  result = up();
  if checkResult(result)
    return(result);
  
  result = left();
  if checkResult(result)
    return(result);
  
  result = down();
  if checkResult(result)
    return(result);
  </code></pre>
  
  <p>So it's kind of priority. I know that one of them would work. But I need to check it according to priority: <code>[right, up, left, down]</code>.</p>
  
  <p>Now, the trick is: my priority changes over time. To be precise it depends on previous move. So:</p>
  
  <pre><code>if previous move was up(), then priority is [right, up, left, down]
  if previous move was left(), then priority is [up, left, down, right]
  if previous move was down(), then priority is [left, down, right, up]
  </code></pre>
  
  <p>So you can clearly see the logic here. The question is: how do I do call the functions in given (variable) priority? </p>
  
  <p>Obviously, I can just do switch and copy-paste calling block, but that's ugly. So is it an elegant way of doing it?</p>
  
  <p>Furthermore, what are the ways for Java and Python? </p>