typedef struct{R x; R y; R xd; R yd;} pt; pt a[m][n];I adopted an array of arrays of records of four floats. Everything goes swimmingly until I get to
a.(i).(j+1).xd <- a.(i).(j+1).xd -. p1 *. dy.(j)The text “a.(i).(j+1).xd” within “a.(i).(j+1).xd <-” has no meaning as an expression. The expression to the left of “+=” in C is an ‘l-value’ whose official definition I find obscure. The Algol 68 analog met this conundrum head on and the concepts were clear but not simple. Here is the bulkier slower working version whose output matches the C code exactly. (See the ap and av functions here. I have not decided to back port them.) The address of a record is calculated twice for each +:= and this dominates the cost of the calculation.
After adding graphics to this code (below) I begin to study the pragmatics of the version described just above.
A still from the movie
This version maintains a positive pressure for triangles with negative area which is normally be avoided. Also added is an optional friction, “f”, on the boundary—a sort of viscosity.
This version is instrumented to learn about the distribution of pressures in order to color code triangles according to their pressure. Every time you type a “q” in place of a numeral, the pressures are ranked and 20 equal steps in the ranking are printed.
So far the programs are like the 650 version but with graphics added. Now we use new language features for a more modern version. This version shrinks by abstracting 2D vectors as tuples . We do arithmetic on the vectors with operators +^ -^ *^ *^. and !^. If x is a real and v a vector then “x *^ v” is scalar multiplication of the vector. “u *^. v” is the dot product between two vectors. The prefix operator “!^” rotates a vector counter-clockwise by 90 degrees. Vectors presumably halve the cost of computing addresses in the 2D array.
Here we reincorporate the graphics.
These modifications leave intact the extreme hacks to save space and work. We rely weakly on tail recursion only.
To be done: