Re: Clair Grant on VMS code base

Liste des GroupesRevenir à co vms 
Sujet : Re: Clair Grant on VMS code base
De : bill.gunshannon (at) *nospam* gmail.com (bill)
Groupes : comp.os.vms
Date : 17. Apr 2025, 15:08:26
Autres entêtes
Message-ID : <m6cgatF8fe6U3@mid.individual.net>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 4/17/2025 8:56 AM, Arne Vajhøj wrote:
On 4/17/2025 8:50 AM, Simon Clubley wrote:
On 2025-04-17, bill <bill.gunshannon@gmail.com> wrote:
On 4/16/2025 9:29 PM, Dan Cross wrote:
Most modern code-counting tools _are_ language aware.  Whether
they do a better or worse job for each given language may be a
matter of debate, but most at least recognize different
languages and have some knowledge of their semantics.
>
I wonder how they would handle BASIC?  :-)
>
10 FOR X = 1 TO 10
20 PRINT X
30 NEXT X
>
10 FOR X = 1 TO 10:PRINT X:NEXT X
>
Is the snippet above one line of code or three?
>
3 lines of code.
 Other replies cover what the tools actually does.
 If we discuss what is the "right" answer, then I would
actually say 2.
 for i := 1 to 10 do writeln(i)
 for i := 1 to 10 do
    writeln(i)
 for i := 1 to 10 do begin
    writeln(i)
end;
 for i := 1 to 10 do
begin
    writeln(i)
end;
 for(i = 1; i <= 10; i++) printf("%d\n", i);
 for(i = 1; i <= 10; i++)
     printf("%d\n", i);
 for(i = 1; i <= 10; i++) {
     printf("%d\n", i);
}
 for(i = 1; i <= 10; i++)
{
     printf("%d\n", i);
}
 I would say 2 for all.
 And unless Basic next has some subtle functionality I am not
aware of then I would say 2 for Basic as well.
 
Interesting concept.  But the NEXT is a requirement of the
language, does take time to type and if it is left out does
require debugging to fix the problem.  So, if we are counting
lines in some attempt to determine the cost of writing and
maintaining the program it seems it would have to count as
a line.   If you are going to determine what constitutes a
valid line by comparing other languages then the whole thing
just become silly.
Sieve of Eratosthenes
APL:
sieve2←{
   b←⍵⍴1
   b[⍳2⌊⍵]←0
   2≥⍵:b
   p←{⍵/⍳⍴⍵}∇⌈⍵*0.5
   m←1+⌊(⍵-1+p×p)÷p
   b ⊣ p {b[⍺×⍺+⍳⍵]←0}¨ m
}
COBOL:
        IDENTIFICATION DIVISION.
        PROGRAM-ID. Sieve-Of-Eratosthenes.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01  Max-Number       USAGE UNSIGNED-INT.
        01  Max-Prime        USAGE UNSIGNED-INT.
        01  Num-Group.
            03  Num-Table PIC X VALUE "P"
                    OCCURS 1 TO 10000000 TIMES DEPENDING ON Max-Number
                    INDEXED BY Num-Index.
                88  Is-Prime VALUE "P" FALSE "N".
        01  Current-Prime    USAGE UNSIGNED-INT.
        01  I                USAGE UNSIGNED-INT.
        PROCEDURE DIVISION.
            DISPLAY "Enter the limit: " WITH NO ADVANCING
            ACCEPT Max-Number
            DIVIDE Max-Number BY 2 GIVING Max-Prime
*          *> Set Is-Prime of all non-prime numbers to false.
            SET Is-Prime (1) TO FALSE
            PERFORM UNTIL Max-Prime < Current-Prime
*              *> Set current-prime to next prime.
                ADD 1 TO Current-Prime
                PERFORM VARYING Num-Index FROM Current-Prime BY 1
                    UNTIL Is-Prime (Num-Index)
                END-PERFORM
                MOVE Num-Index TO Current-Prime
*              *> Set Is-Prime of all multiples of current-prime to
*              *> false, starting from current-prime sqaured.
                COMPUTE Num-Index = Current-Prime ** 2
                PERFORM UNTIL Max-Number < Num-Index
                    SET Is-Prime (Num-Index) TO FALSE
                    SET Num-Index UP BY Current-Prime
                END-PERFORM
            END-PERFORM
*          *> Display the prime numbers.
            PERFORM VARYING Num-Index FROM 1 BY 1
                    UNTIL Max-Number < Num-Index
                IF Is-Prime (Num-Index)
                    DISPLAY Num-Index
                END-IF
            END-PERFORM
            GOBACK
            .
PL/M:
100H:
DECLARE PRIME$MAX LITERALLY '5000';
/* CREATE SIEVE OF GIVEN SIZE */
MAKE$SIEVE: PROCEDURE(START, SIZE);
     DECLARE (START, SIZE, M, N) ADDRESS;
     DECLARE PRIME BASED START BYTE;
     PRIME(0)=0; /* 0 AND 1 ARE NOT PRIMES */
     PRIME(1)=0;
     DO N=2 TO SIZE;
         PRIME(N)=1; /* ASSUME ALL OTHERS ARE PRIME AT BEGINNING */
     END;
     DO N=2 TO SIZE;
         IF PRIME(N) THEN DO; /* IF A NUMBER IS PRIME... */
             DO M=N*N TO SIZE BY N;
                 PRIME(M) = 0; /* THEN ITS MULTIPLES ARE NOT */
             END;
         END;
     END;
END MAKE$SIEVE;
/* CP/M CALLS */
BDOS: PROCEDURE(FUNC, ARG);
     DECLARE FUNC BYTE, ARG ADDRESS;
     GO TO 5;
END BDOS;
DECLARE BDOS$EXIT  LITERALLY '0',
         BDOS$PRINT LITERALLY '9';
/* PRINT A 16-BIT NUMBER */
PRINT$NUMBER: PROCEDURE(N);
     DECLARE (N, P) ADDRESS;
     DECLARE S (8) BYTE INITIAL ('.....',10,13,'$');
     DECLARE C BASED P BYTE;
     P = .S(5);
DIGIT:
     P = P - 1;
     C = (N MOD 10) + '0';
     N = N / 10;
     IF N > 0 THEN GO TO DIGIT;
     CALL BDOS(BDOS$PRINT, P);
END PRINT$NUMBER;
/* PRINT ALL PRIMES UP TO N */
PRINT$PRIMES: PROCEDURE(N, SIEVE);
     DECLARE (I, N, SIEVE) ADDRESS;
     DECLARE PRIME BASED SIEVE BYTE;
     CALL MAKE$SIEVE(SIEVE, N);
     DO I = 2 TO N;
         IF PRIME(I) THEN CALL PRINT$NUMBER(I);
     END;
END PRINT$PRIMES;
CALL PRINT$PRIMES(PRIME$MAX, .MEMORY);
CALL BDOS(BDOS$EXIT, 0);
EOF
bill

Date Sujet#  Auteur
1 Apr 25 * Clair Grant on VMS code base55Arne Vajhøj
1 Apr 25 +* Re: Clair Grant on VMS code base5Dan Cross
1 Apr 25 i`* Re: Clair Grant on VMS code base4Arne Vajhøj
1 Apr 25 i +- Re: Clair Grant on VMS code base1Dan Cross
1 Apr 25 i `* Re: Clair Grant on VMS code base2Lawrence D'Oliveiro
2 Apr 25 i  `- Re: Clair Grant on VMS code base1Arne Vajhøj
3 Apr 25 `* Re: Clair Grant on VMS code base49Simon Clubley
3 Apr 25  +* Re: Clair Grant on VMS code base45Arne Vajhøj
4 Apr 25  i`* Re: Clair Grant on VMS code base44Simon Clubley
4 Apr 25  i +- Re: Clair Grant on VMS code base1Rich Alderson
7 Apr 25  i `* Re: Clair Grant on VMS code base42Arne Vajhøj
7 Apr 25  i  +- Re: Clair Grant on VMS code base1Arne Vajhøj
7 Apr 25  i  +* Re: Clair Grant on VMS code base3Lawrence D'Oliveiro
7 Apr 25  i  i`* Re: Clair Grant on VMS code base2Lawrence D'Oliveiro
7 Apr 25  i  i `- Re: Clair Grant on VMS code base1Arne Vajhøj
8 Apr 25  i  `* Re: Clair Grant on VMS code base37Simon Clubley
8 Apr 25  i   `* Re: Clair Grant on VMS code base36Arne Vajhøj
8 Apr 25  i    +- Re: Clair Grant on VMS code base1abrsvc
8 Apr 25  i    `* Re: Clair Grant on VMS code base34Simon Clubley
11 Apr 25  i     `* Re: Clair Grant on VMS code base33Arne Vajhøj
11 Apr 25  i      +- Re: Clair Grant on VMS code base1Arne Vajhøj
14 Apr 25  i      `* Re: Clair Grant on VMS code base31Simon Clubley
14 Apr 25  i       `* Re: Clair Grant on VMS code base30Dave Froble
14 Apr 25  i        +* Re: Clair Grant on VMS code base3Simon Clubley
16 Apr 25  i        i`* Re: Clair Grant on VMS code base2Dave Froble
17 Apr 25  i        i `- Re: Clair Grant on VMS code base1Dan Cross
16 Apr 25  i        `* Re: Clair Grant on VMS code base26Arne Vajhøj
17 Apr 25  i         `* Re: Clair Grant on VMS code base25Dan Cross
17 Apr 25  i          +* Re: Clair Grant on VMS code base18bill
17 Apr 25  i          i+* Re: Clair Grant on VMS code base6Arne Vajhøj
17 Apr 25  i          ii`* Re: Clair Grant on VMS code base5bill
17 Apr 25  i          ii +- Re: Clair Grant on VMS code base1Arne Vajhøj
17 Apr 25  i          ii `* Re: Clair Grant on VMS code base3Simon Clubley
17 Apr 25  i          ii  `* Re: Clair Grant on VMS code base2bill
17 Apr 25  i          ii   `- Re: Clair Grant on VMS code base1Simon Clubley
17 Apr 25  i          i`* Re: Clair Grant on VMS code base11Simon Clubley
17 Apr 25  i          i `* Re: Clair Grant on VMS code base10Arne Vajhøj
17 Apr 25  i          i  +* Re: Clair Grant on VMS code base4bill
17 Apr 25  i          i  i`* Re: Clair Grant on VMS code base3Arne Vajhøj
17 Apr 25  i          i  i `* Re: Clair Grant on VMS code base2bill
17 Apr 25  i          i  i  `- Re: Clair Grant on VMS code base1Arne Vajhøj
18 Apr 25  i          i  `* Re: Clair Grant on VMS code base5Lawrence D'Oliveiro
18 Apr 25  i          i   +* Re: Clair Grant on VMS code base3Arne Vajhøj
18 Apr 25  i          i   i+- Re: Clair Grant on VMS code base1Lawrence D'Oliveiro
19 Apr 25  i          i   i`- Re: Clair Grant on VMS code base1Waldek Hebisch
19 Apr 25  i          i   `- Re: Clair Grant on VMS code base1Waldek Hebisch
17 Apr 25  i          +* Re: Clair Grant on VMS code base4Arne Vajhøj
17 Apr 25  i          i`* Re: Clair Grant on VMS code base3Dan Cross
18 Apr 25  i          i `* Re: Clair Grant on VMS code base2Dave Froble
18 Apr 25  i          i  `- Re: Clair Grant on VMS code base1Dan Cross
17 Apr 25  i          `* Re: Clair Grant on VMS code base2Arne Vajhøj
17 Apr 25  i           `- Re: Clair Grant on VMS code base1Dan Cross
9 Apr 25  `* Re: Clair Grant on VMS code base3John Reagan
9 Apr 25   `* Re: Clair Grant on VMS code base2Lawrence D'Oliveiro
11 Apr 25    `- Re: Clair Grant on VMS code base1Arne Vajhøj

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal