💾 Archived View for gemini.spam.works › mirrors › textfiles › humor › COMPUTER › weird.pro captured on 2022-07-17 at 02:38:11.
⬅️ Previous capture (2022-06-12)
-=-=-=-=-=-=-
From dnalib@KCVAX.LDC.LU.SE Mon Oct 2 16:13:23 1989 Date: Fri, 29 Sep 89 11:00:00 EET Reply-To: Magnus Olsson <dnalib@KCVAX.LDC.LU.SE> Sender: Nutworks magazine & Other Nutty Stuff <NUTS@FINHUTC> From: Magnus Olsson <dnalib@KCVAX.LDC.LU.SE> Subject: Bored By Pascal? To: Timo Kiravuo <kiravuo@KAMPI.HUT.FI> Hi there! Since this list seems to be silently dying, I'll try to revive it by actually *posting* something. The following files were circulating on the one of the Vaxen at the dept. of Computer Science here in Lund a few years ago. Nothing seems to be known about the author, except that he's never existed... By the way, all three programs compile and run under VAX/VMS. For non-VAXers, the MTH$RANDOM function in the second program returns a random real between 0 and 1. Have fun! Magnus (DNALIB@SELDC51) ___________________________BORED-1.FOR_______________________________________ C BORED BY PASCAL? C ================ C PASCAL IS DESIGNED SO THAT YOU DON'T HAVE TO THINK C WHILE PROGRAMMING. THIS IS GOOD FOR BEGINNERS BUT WILL C BECOME A LITTLE BORING AFTER A WHILE. C THIS LITTLE PROGRAM WAS WRITTEN TO DEMONSTRATE A C NICE FEATURE OF FORTRAN: THE POSSIBILITY OF WRITING C I N T E R E S T I N G CODE. C IF THIS PROGRAM WERE WRITTEN IN PASCAL, IT WOULD BE QUITE C BANAL AND EASILY UNDERSTANDABLE EVEN TO THE AVERAGE TLTH C MEMBER. THAT WOULD BE NO FUN, HOWEVER. C C NOTE THE FOLLOWING NICETIES: C * THE ABSENCE OF SENSIBLE COMMENTS-REAL PROGRAMMERS UNDERSTAND C FORTRAN BETTER THAN ENGLISH! C * THE ARITHMETIC IF-STATEMENTS (ADDING NICE FLAVOUR TO C THE CODE) C * THE WONDERFULLY CONCISE VARIABLE NAMES C * THE H-FORMAT FOR ALPHANUMERIC OUTPUT ( A LIVING FOSSIL C FROM THE HAPPY DAYS OF THE PUNCHED CARD) C * THE NICE SPAGHETTI STRUCTURE - STRUCTURED PROGRAMMING C IS ONLY FOR AMATEURS AND OLD LADIES C C A SMALL REWARD IS OFFERED TO ANYBODY ABLE TO SAY WHAT C THIS PROGRAM DOES (WITHOUT ACTUALLY RUNNING IT) C SEND YOUR ANSWERS TO TOM A.CRONA, C DEPARTMENT OF COMMUTER SCIENCE C AND NUMERICAL SYNTHESIS, C UNIVERSITY OF LUND C C PLEASE NOTE THAT THIS PROGRAM IS NOT IN ANY WAY PATHOLOGICAL C BUT A PERFECTLY NORMAL EXAMPLE OF WHAT PROGRAMMING WAS LIKE C BACK IN THE GOLDEN DAYS WHEN COMPUTERS WERE COMPUTERS AND C PROGRAMMERS WERE PROGRAMMERS... 10 WRITE (*,487) READ (*,*) N IF (N) 10,10,30 30 I1=2 97 I2=0 60 J=MOD(N,I1) IF (J) 40,50,40 50 I2=I2+1 N=N/I1 GOTO 60 40 IF (I2-1) 70,80,90 70 I1=I1+2 IF (I1-4) 120,135,120 135 I1=3 120 IF (I1-N) 97,97,3 3 WRITE (*,65) READ (*,*) I3 IF (I3) 3,130,10 130 STOP 80 WRITE (*,855) I1 GOTO 70 90 WRITE (*,930) I1,I2 GOTO 70 487 FORMAT (8H NUMBER?/) 65 FORMAT (20H CONTINUE? (1=Y,0=N)/) 855 FORMAT (I5) 930 FORMAT (I5,3H **,I5) C BE A CREATIVE PROGRAMMER - USE FORTRAN C (C) SFRGOD (The Society For Revival of the Good Old C Days), Fortran section, 1984 END ____________________________BORED-2.PAS_________________________________________ { BORED BY PASCAL? part 2 ========================== In this degenerate age of the toy computer (by some weak souls called "personal computer" or something like that) everyone learns programming in kindergarten or at least in high school (if there's any difference between those school forms). For this activity, a language called BASIC is used almost exclusively. BASIC is rather like a small subset of FORTRAN with many of its good features amputated but with all of its drawbacks. Anyway, you can write all kinds of programs in BASIC, and since it (fortunately!) lacks any trace of structured constructs it promotes creative programming the same way FORTRAN does and you get programmers who THINK while they're programming. When these persons start a higher education, they are forced to write their programs in a "language" called Pascal and are thereby quickly converted into well-adapted quiche eaters without a trace of originality. This paper was written to point out a method of solving this problem. Actually, you don't have to learn Pascal at all - it's much easier to write your programs in BASIC and then translate them directly into Pascal. As an example, consider the following program. It was originally written in BASIC on a ZX80 (Yecch!) and then transformed into syntactically perfect Pascal during the pause between two lectures. Most Pascal addicts turn away in disgust when seeing the words GOTO and LABEL, but there's absolutely no reason to discriminate these constructs - after all they're a part of the language (if that's not too strong a word to use about Pascal). Why should any programmer reject what is good enough for the compiler? Besides, the GOTO was there first - structured programming is a much later (and unnecessary) addition. By following this recipe, the young, undestroyed programmers can continue writing their programs in BASIC, avoid learning more Pascal than absolutely necessary and at the same time satisfy the Pascal buffs of the university. } PROGRAM NIM (INPUT,OUTPUT); {(c) Tom A. Crona 1984} LABEL 70,90,150,230,280,370,400,460,470,520,540,800,810,820; VAR J,S1,D,E,H,R,K : INTEGER; { WHO NEEDS FANCY LONG VARIABLE NAMES?} A,B : ARRAY [0..3] OF INTEGER; C : ARRAY [0..3,0..3] OF INTEGER; FUNCTION MTH$RANDOM(VAR SEED:INTEGER):REAL; EXTERNAL; BEGIN WRITELN ('******* NIM *******'); WRITELN ('I HOPE YOU KNOW THE RULES OF NIM.'); WRITELN ('ANYWAY I''M NOT GOING TO RECITE THEM...'); WRITELN ('ENTER RANDOM SEED'); READ(S1); 70:FOR D:=0 TO 3 DO A[D]:=TRUNC(MTH$RANDOM(S1)*15+1); 90:FOR D:=0 TO 3 DO WRITELN (D+1,':',A[D]:2); IF A[0]+A[1]+A[2]+A[3]>0 THEN GOTO 150; WRITELN ('*I WON*'); GOTO 540; 150:WRITELN ('WHICH PILE?'); READ (D); IF (D<1) OR (D>4) THEN GOTO 800; WRITELN ('HOW MANY?'); READ (E); IF (E<1) OR (E>A[D-1]) THEN GOTO 810; A[D-1]:=A[D-1]-E; D:=-1; 230:D:=D+1; IF D=4 THEN GOTO 460; FOR E:=0 TO 3 DO B[E]:=A[E]; 280:B[D]:=B[D]-1; IF B[D]<0 THEN GOTO 230; FOR E:=0 TO 3 DO BEGIN H:=B[E]; R:=16; FOR J:=0 TO 3 DO BEGIN C[J,E]:=0; R:=R DIV 2; IF H<R THEN GOTO 370; C[J,E]:=1; H:=H-R; 370:END; END; E:=-1; 400:E:=E+1; H:=C[E,0]+C[E,1]+C[E,2]+C[E,3]; IF H MOD 2>0 THEN GOTO 280; IF E<3 THEN GOTO 400; A[D]:=B[D]; GOTO 90; 460:D:=-1; 470:D:=D+1; IF D=4 THEN GOTO 520; IF A[D]=0 THEN GOTO 470; A[D]:=A[D]-TRUNC(MTH$RANDOM(S1)*A[D]+1); GOTO 90; 520:WRITELN ('YOU WON.'); 540:WRITELN ('ENTER 1 IF YOU WISH TO CONTINUE, 0 OTHERWISE'); READ (K); IF K=1 THEN GOTO 70; GOTO 820; 800:WRITELN ('THERE IS NO SUCH PILE, STUPID!!!'); GOTO 150; 810:WRITELN ('TRYING TO CHEAT, EH?'); GOTO 150; 820:END. ______________________________BORED-3.COB__________________________________