• My take on DO, was Re: push for memory safe languages ...

    From albert@spenarnc.xs4all.nl@21:1/5 to All on Wed Mar 13 14:30:00 2024
    - DOxxx performs the loop
    - Indices are integers.
    - forms of DO
    one-bound {BODY} DO) \ 0 ... one-bound-1
    one-bound {BODY} DO] \ 1 ... one-bound
    b1 b2 {BODY} DO[] \ b1 .. b2
    b1 b2 stride {BODY} DO[..] \ b1 b1+stride b1+2*stride .. b2

    Maybe
    b1 b2 {BODY} DO[) \ b1 .. b2-1
    to accommodate
    array length OVER + {BODY} DO[)

    Note the stride is now constant obviously.
    If it is negative, the loop goes down.
    If you want to straddle from positive to negative (addresses?),
    program it explicitly and conspicuously.

    Note 1
    The [ ) convention comes from mathematics, example:
    [1,9] interval 1 2 3 4 5 6 7 8 9
    [1,9) interval 1 2 3 4 5 6 7 8
    (0,9) interval 1 2 3 4 5 6 7 8

    Note 2
    {BODY} leans heavily on [: ;] presence. (Or ciforth's { } )

    Note 3
    If you want to change the stride mid-program, you have to
    use BEGIN WHILE REPEAT, as you should have done in the first place.

    The four DO's replace the four don't's : ?DO DO LOOP +LOOP .

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Wed Mar 13 13:53:14 2024
    Also handy When you have list types:

    (( 1 2 3 5 7 11 13 17 )) DO-WITH ..

    or

    (( H2 O2 CO CO2 )) DO-WITH ..
    where H2 et al can be numbers/addresses or arrays/strings

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)