Post Reply 
newRPL - Updated to build 1510 [official build remains at 1487]
08-11-2021, 02:56 AM
Post: #168
RE: newRPL - Updated to build 1487 [ including official build]
Fortran (starting in Fortran 77) uses the equivalent formulation:

DO I=k1,k2,k3
...
ENDDO

where k1 is the start, k2 the end, and k3 the increment. There is a formula giving the number of cycles. If k2-k1>0 and k3 is positive (default +1), then (k1-k2)/k3 gives the number of iterations (think the floor is used as zero or negative trip loops are skipped). A negative k3 runs the loop backward. The trip count is computed before the loop started and changes in any of the arguments within the loop are ignored. I preferred using DO I=k1:k2:k3 in line with Fortran's list constructors but the commas have been used since 1954. (Fortran is mostly backward compatible.)

The "mandatory one trip" loop did exist in non-standard Fortrans and (I think) Fortran 66.

The 77 style loops are mainly used for array manipulation. Earlier style control structures are more easily (and flexibly) handled by IF constructs and GOTOs. Most array manipulations can even be used with Fortran 90s array stuff.

As an aside, while working on the Fortran standard, I put together an array-oriented language that had some unusual stuff. Loops used the Fortran 77 loop starting but allowed the index to be varied as the array operations handled everything else. Arrays used C=A op B for the usual (+ - * / ^ ) for conformable arrays. Dummy bound arguments for the linear algebra of tensor stuff. Matrix multiply: C(*i, *j) = A(*i, %k)*B(%k, *j) or something similar: *s represented ordinary bound variables running over array bounds and %s represented bound variables summed over. (Or maybe other symbols.) It was convenient enough that I still write formulas this way, then convert to Fortran (or whatever.)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - Updated to build 1487 [ including official build] - ttw - 08-11-2021 02:56 AM
Navigating through sub-menus - Gilles - 05-13-2023, 11:31 AM
It's a mystery to me... - Klaus - 11-27-2023, 12:24 PM



User(s) browsing this thread: 3 Guest(s)