I've only tested these in Applesoft, but they should all run in EhBASIC.
Can you predict what this 5 liner is going to output without RUNning it? Better yet, can you explain why this works?
Code:
10 P=3
20 FOR I=1 TO 5
30 PRINT P
40 P=P+SIN(P)
50 NEXT
A 12 liner.
Code:
100 DIM N(104)
110 FOR T=1 TO 104:N(T)=2:NEXT
120 FOR D=1 TO 31
130 Q=0
140 FOR T=104 TO 1 STEP -1
150 B=2*T-1
160 IF T=1 THEN B=10
170 R=T*Q+N(T)*10:Q=INT(R/B):N(T)=R-Q*B
180 NEXT
190 PRINT Q;
200 IF D=1 THEN PRINT ".";
210 NEXT
This one is for 80 columns (where the characters about twice as tall as they are wide).
Code:
10 P=ATN(1)*4
20 FOR Y = -10.5 TO 10.5
30 FOR X = -10.75 TO 10.75 STEP .5
40 A=ATN(Y/X)+(X<0)*SGN(Y)*P
50 C=(SQR(X*X+Y*Y)-A/2)/P
60 PRINT CHR$(32+3*(C-INT(C)<.4));
70 NEXT
80 PRINT
90 NEXT
For 40 columns (where the characters are roughly square, i.e. they are about as tall as they are wide), I changed line 30 to this:
Code:
30 FOR X = -10.5 TO 10.5
A quine. (I didn't bother to match the spacing, since the different versions of Applesoft LIST with slightly different spacing, but it's not too difficult to fix that (or to replace ? with PRINT), if you want to have at it.)
Code:
1A$=":A$=CHR$(34)+A$:?1MID$(A$,3,3)A$A$":A$=CHR$(34)+A$:?1MID$(A$,3,3)A$A$
Rule 30 (with wraparound). I used W=39 (line 10) for 40 columns.
Code:
10 W=79
20 DIM A(W+1):A(W/2+1)=1
30 FOR I=0 TO 7:B(I)=ASC(MID$("00011110",8-I))-48:NEXT
40 P=A(W):A(W+1)=A(1):FOR I=1 TO W:N=A(I)
50 PRINT CHR$(32+3*N);
60 A(I)=B(4*P+2*N+A(I+1)):P=N:NEXT:PRINT
70 GOTO 40