2048: Difference between revisions

Line 2,164:
 
Holding firmly to the one-dimensional aspect of the row's processing, the actual processing can be seen to be simple. For instance, step along an array comparing each element to its predecessor, as in A(I) and A(I - 1), or, (avoiding index arithmetic) maintain two indices: CI and PI for current and previous index. Start CI at element one, and run the loop as <code>DO L = 2,N</code> with on each iteration PI taking the value of CI, and CI being calculated afresh. Except that the loop has verbiage: DO L = ''(first'' + ''increment)'',''last'',''increment''.
 
But in fact, the board is represented as a two dimensional array. Fortran does not offer a special "index" type of variable so that if ''this'' was a two-element entity with the value (1,2), <code>A(this)</code> would be equivalent to <code>A(1,2)</code> One must write out the indices, as in <code>A(this(1),this(2))</code> On the other hand, F90 introduced array arithmetic and related statements, so one can declare CIJ to be a two-element array, and introduce array arithmetic similar to complex number arithmetic to juggle indices.
 
===Source===
1,220

edits