• Re: The joy of FORTRAN

    From Kerr-Mudd, John@admin@127.0.0.1 to alt.folklore.computers,comp.lang.rexx on Sat Sep 28 09:33:23 2024
    From Newsgroup: comp.lang.rexx

    On 27 Sep 2024 14:17:38 GMT
    Bob Eager <news0009@eager.cx> wrote:

    On Fri, 27 Sep 2024 11:52:04 +0000, Bob Martin wrote:

    On 27 Sep 2024 at 11:10:37, The Natural Philosopher
    <tnp@invalid.invalid> wrote:
    On 27/09/2024 11:32, Kerr-Mudd, John wrote:
    On Thu, 26 Sep 2024 20:51:25 -0000 (UTC) Lawrence D'Oliveiro
    <ldo@nz.invalid> wrote:

    On Thu, 26 Sep 2024 16:18:01 GMT, Charlie Gibbs wrote:

    One of the favourite functions in my library pulls the next token
    from a delimited string, but as opposed to strtok() it does it
    non-destructively and can handle empty strings.

    Use a high-level language which has all this and more:

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    Output:

    the quick brown fox

    In Python, strings are objects, and that applies to string
    expressions (including string literals) as well.

    You need Rexx

    NOBODY needs REGEX!

    He said Rexx; very superior language, written by a Brit at IBM Hursley
    45 years ago,
    Was, maybe still is, the default language on IBM mainframes.

    https://sourceforge.net/projects/oorexx/files/

    And for the original non O-O version:

    https://sourceforge.net/projects/regina-rexx/


    I was too lazy to dig into my rusty brain to code the equivalent in Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end
    w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.


    xpost to comp.lang.rexx, if it still exists
    --
    Bah, and indeed Humbug.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Bob Eager@news0009@eager.cx to alt.folklore.computers,comp.lang.rexx on Sat Sep 28 09:41:59 2024
    From Newsgroup: comp.lang.rexx

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end
    ------------------------------------------
    --
    Using UNIX since v6 (1975)...

    Use the BIG mirror service in the UK:
    http://www.mirrorservice.org
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Kerr-Mudd, John@admin@127.0.0.1 to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 09:19:10 2024
    From Newsgroup: comp.lang.rexx

    On 28 Sep 2024 09:41:59 GMT
    Bob Eager <news0009@eager.cx> wrote:

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end
    ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not extensively. But Rexx has "Parse" which few(no?) other languages have.
    --
    Bah, and indeed Humbug.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R Daneel Olivaw@Danny@hyperspace.vogon.gov to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 11:23:18 2024
    From Newsgroup: comp.lang.rexx

    Kerr-Mudd, John wrote:
    On 28 Sep 2024 09:41:59 GMT
    Bob Eager <news0009@eager.cx> wrote:

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer:
    https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end
    ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not extensively. But Rexx has "Parse" which few(no?) other languages have.


    What does "parse" do?
    I just had a look at some REXX documentation but it was not particularly helpful, it looked to me to be something which a couple of FORTRAN 77
    function calls would have handled perfectly adequately.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Bob Eager@news0009@eager.cx to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 10:10:14 2024
    From Newsgroup: comp.lang.rexx

    On Sun, 29 Sep 2024 09:19:10 +0100, Kerr-Mudd, John wrote:


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not extensively. But Rexx has "Parse" which few(no?) other languages have.

    The nearest I've seen is the string resolution in Edinburgh IMP. You can
    give pretty well the same kind of pattern, with specified delimiters, and
    it splits the string into variables.

    For example:

    s1 -> s2.(",").s3.("-").s4

    The number of terms is limited only by temporary stack space. I once
    parsed entries in a termcap database using this.

    If the resolution fails, an event is signalled. But you can use the
    resolution as a conditional expression to avoid that, and find out if it failed that way.

    http://www.ancientgeek.org.uk/EMAS/EMAS_Manuals/IMP/
    The_IMP80_Language.pdf

    (bottom of page 26 onwards)
    --
    Using UNIX since v6 (1975)...

    Use the BIG mirror service in the UK:
    http://www.mirrorservice.org
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Bob Eager@news0009@eager.cx to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 10:18:47 2024
    From Newsgroup: comp.lang.rexx

    On Sun, 29 Sep 2024 11:23:18 +0200, R Daneel Olivaw wrote:

    Kerr-Mudd, John wrote:
    On 28 Sep 2024 09:41:59 GMT Bob Eager <news0009@eager.cx> wrote:

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer:
    https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not
    extensively. But Rexx has "Parse" which few(no?) other languages have.


    What does "parse" do?
    I just had a look at some REXX documentation but it was not particularly helpful, it looked to me to be something which a couple of FORTRAN 77 function calls would have handled perfectly adequately.

    It essentially splits a string into substrings, using specified
    delimiters. The source string may be from a variety of places (variable, argument array, input line, stack) and there are some weird special cases
    such as getting the version number.

    Essentially, you specify a template and it splits the string in accordance with that. For example:

    parse var s1 "," s2 "-" s3
    --
    Using UNIX since v6 (1975)...

    Use the BIG mirror service in the UK:
    http://www.mirrorservice.org
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R Daneel Olivaw@Danny@hyperspace.vogon.gov to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 16:47:47 2024
    From Newsgroup: comp.lang.rexx

    Bob Eager wrote:
    On Sun, 29 Sep 2024 11:23:18 +0200, R Daneel Olivaw wrote:

    Kerr-Mudd, John wrote:
    On 28 Sep 2024 09:41:59 GMT Bob Eager <news0009@eager.cx> wrote:

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer:
    https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem >>>>> array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not
    extensively. But Rexx has "Parse" which few(no?) other languages have.


    What does "parse" do?
    I just had a look at some REXX documentation but it was not particularly
    helpful, it looked to me to be something which a couple of FORTRAN 77
    function calls would have handled perfectly adequately.

    It essentially splits a string into substrings, using specified
    delimiters. The source string may be from a variety of places (variable, argument array, input line, stack) and there are some weird special cases such as getting the version number.

    Essentially, you specify a template and it splits the string in accordance with that. For example:

    parse var s1 "," s2 "-" s3





    Ok, similar to "unstring" in COBOL, although unstring is more flexible
    and can tell you which separator was hit if more than one was permitted,
    and probably how many characters were in each extracted substring.

    Unstring had so many possibilities I don't think I ever tried them all.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Peter Flass@peter_flass@yahoo.com to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 13:15:04 2024
    From Newsgroup: comp.lang.rexx

    R Daneel Olivaw <Danny@hyperspace.vogon.gov> wrote:
    Kerr-Mudd, John wrote:
    On 28 Sep 2024 09:41:59 GMT
    Bob Eager <news0009@eager.cx> wrote:

    On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:

    I was too lazy to dig into my rusty brain to code the equivalent in
    Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer:
    https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
    separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    If you use space as a delimiter, which I would argue is more natural:

    ------------------------------------------
    myline="the quick brown fox"

    do i = 1 to words(myline)
    say word(myline, i)
    end
    ------------------------------------------


    Thanks; It's been yea^w decades since I used Rexx. And even then not
    extensively. But Rexx has "Parse" which few(no?) other languages have.


    What does "parse" do?
    I just had a look at some REXX documentation but it was not particularly helpful, it looked to me to be something which a couple of FORTRAN 77 function calls would have handled perfectly adequately.


    What doesnrCOt it do? It breaks down a string according to a pattern, a lot like SNOBOL (IIRC, my use of REXX now is limited to straightforward stuff)
    --
    Pete
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lawrence D'Oliveiro@ldo@nz.invalid to alt.folklore.computers,comp.lang.rexx on Sun Sep 29 23:37:40 2024
    From Newsgroup: comp.lang.rexx

    On Sun, 29 Sep 2024 09:19:10 +0100, Kerr-Mudd, John wrote:

    But Rexx has "Parse" which few(no?) other languages have.

    Given that Rexx example is so much more wordy than my Python original,
    perhaps that should come as no surprise.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From lar3ryca@larry@invalid.ca to alt.folklore.computers,comp.lang.rexx on Tue Oct 8 19:53:39 2024
    From Newsgroup: comp.lang.rexx

    On 2024-09-28 02:33, Kerr-Mudd, John wrote:
    On 27 Sep 2024 14:17:38 GMT
    Bob Eager <news0009@eager.cx> wrote:

    On Fri, 27 Sep 2024 11:52:04 +0000, Bob Martin wrote:

    On 27 Sep 2024 at 11:10:37, The Natural Philosopher
    <tnp@invalid.invalid> wrote:
    On 27/09/2024 11:32, Kerr-Mudd, John wrote:
    On Thu, 26 Sep 2024 20:51:25 -0000 (UTC) Lawrence D'Oliveiro
    <ldo@nz.invalid> wrote:

    On Thu, 26 Sep 2024 16:18:01 GMT, Charlie Gibbs wrote:

    One of the favourite functions in my library pulls the next token >>>>>>> from a delimited string, but as opposed to strtok() it does it
    non-destructively and can handle empty strings.

    Use a high-level language which has all this and more:

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    Output:

    the quick brown fox

    In Python, strings are objects, and that applies to string
    expressions (including string literals) as well.

    You need Rexx

    NOBODY needs REGEX!

    He said Rexx; very superior language, written by a Brit at IBM Hursley
    45 years ago,
    Was, maybe still is, the default language on IBM mainframes.

    https://sourceforge.net/projects/oorexx/files/

    And for the original non O-O version:

    https://sourceforge.net/projects/regina-rexx/


    I was too lazy to dig into my rusty brain to code the equivalent in Rexx,
    I was hoping someone here would do it!

    for item in "the,quick,brown,fox".split(",") :
    print(item)
    #end for

    OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-separator


    myline="the,quick,brown,fox"

    do i = 1 by 1 while myline <> ''
    parse var myline w.i ',' myline
    end
    w.0 = i-1

    do i = 1 to w.0
    say w.i
    end


    Hmm, must be a shorter way without the bother of setting up the stem
    array.

    But stem variables are SO much fun. Here's one I wrote many years ago
    with ARexx, modified to run on Linux. It's better than uniq as the file
    need not be pre-sorted

    #!/usr/bin/rexx
    /* Show only one copy of each line in a whole file */
    seen. = 0
    Do While Lines() > 0
    Parse Pull this_line
    If seen.this_line Then Iterate
    seen.this_line = 1
    Say this_line
    end


    xpost to comp.lang.rexx, if it still exists
    --
    Computers follow your orders, not your intentions.

    --- Synchronet 3.21d-Linux NewsLink 1.2