Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-02 - decus/20-0028/alis.lst
There is 1 other file named alis.lst in the archive. Click here to see a list.
SNOBOL4 (VERSION 3.4.3,  JAN. 16, 1971)


DIGITAL EQUIPMENT CORP., PDP-10

1
        *
        *	THIS PROGRAM USES PROGRAMMER-DEFINED DATA TYPES TO
        *	REPRESENT AN ARBITRARILY LONG INTEGER AS A LINKED LIST
        *	CALLED ALI.  OPSYN IS USED TO DEFINE A BINARY OPERATOR
        *	AND TWO UNARY OPERATORS FOR MANIPULATING ALIS.
        *
        *	% APPENDS A NODE TO THE HEAD OF A LIST.  # AND / RETURN
        *	THE VALUE OF THE HEAD OF THE LIST, AND THE LIST LINKED
        *	FROM THE HEAD, RESPECTIVELY.
        *
        *	THE OPERATORS + AND * ARE GENERALIZED TO RETURN INTEGERS
        *	IF THE OPERANDS ARE INTEGERS AND THE RESULT LESS THAN
        *	MAX (10000).  IF THE RESULT IS GREATER THAN MAX, AN ALI
        *	IS GENERATED WITH THE VALUE OF THE HEAD EQUAL TO THE LOW
        *	ORDER DIGITS, AND THE LINK POINTING TO AN ALI WITH THE
        *	HIGHER DIGITS.  IF EITHER OPERAND IS AN ALI, THE RESULT
        *	IS AN ALI.
        *
        *	THE USE OF ALIS IS ILLUSTRATED BY COMPUTING THE FIRST K
        *	POWERS OF AN INTEGER N.
        *
        *
2       	&ANCHOR = 1
3       	OPSYN('SUM','+',2)
4       	OPSYN('PROD','*',2)
5       	DATA('ALI(V,L)')
6       	DEFINE('OUT(OUT)')
7       	DEFINE('APPEND(V,L)')
8       	DEFINE('ADD(I1,I2)C')
9       	DEFINE('MUL(I1,I2)C')
10      	DEFINE('VAL(VAL)')
11      	DEFINE('LINK(I)')
12      	OPSYN('+','ADD',2)
13      	OPSYN('*','MUL',2)
14      	OPSYN('%','APPEND',2)
15      	OPSYN('/','LINK',1)
16      	OPSYN('#','VAL',1)
17      	MAX	=  10000
18      	ADDFIX  =  RTAB(SIZE(MAX) - 1) . C REM . ADD
19      	MULFIX  =  RTAB(SIZE(MAX) - 1) . C REM . MUL
        *		FUNCTION DEFINITIONS
        *
20      						:(FEND)
        *
21      APPEND	APPEND   =  ALI(V,L)			:(RETURN)
        *
        *
22      ADD	ADD      =  IDENT(I2)  I1		:S(RETURN)
23      	ADD	 =  IDENT(I1)  I2		:S(RETURN)
24      	ADD	 =  SUM(#I1,#I2)
25      	 LT(ADD,MAX)  INTEGER(I1)  INTEGER(I2)	:S(RETURN)
26      	ADD	 =  LT(ADD,MAX)  ADD % (/I1 + /I2)   :S(RETURN)
27      	ADD	ADDFIX
28      	ADD	= ADD % (C + (/I1 + /I2))	:(RETURN)
        *
29      LINK	LINK	=  \INTEGER(I)  L(I)		:(RETURN)
        *
30      VAL	VAL	=  \INTEGER(VAL)  V(VAL)		:(RETURN)
        *
        *
        *
31      OUT	OUT	=  IDENT(/OUT)  #OUT		:S(RETURN)
32      	OUT	=  OUT(/OUT) DUPL('0',SIZE(MAX) - SIZE(#OUT) - 1)
32      +				#OUT		:(RETURN)
        *
        *
33      MUL	MUL	=  DIFFER(#I1) DIFFER(#I2) PROD(#I1,#I2) :F(RETURN)
34      	LT(MUL,MAX) INTEGER(I1)  INTEGER(I2)	:S(RETURN)
35      	MUL	=  LT(MUL,MAX)  MUL % ( I1 * /I2  +  I2 * /I1)
35      +						:S(RETURN)
36      	MUL	MULFIX
37      	MUL	=  MUL % (C +  I1 * /I2  +  I2 * /I1)
37      +						:(RETURN)
38      FEND
39      	N	=  256
40      	K	=  15
41      	P	=  1
42      	OUTPUT	=  'POWERS OF '  N
43      	OUTPUT	=
44      L	I	=  LT(I,K)  I + 1		:F(END)
45      	P	=  P  *  N
46      	OUTPUT	=  I  ': '  OUT(P)		:(L)
47      END

NO ERRORS DETECTED IN SOURCE PROGRAM

 
POWERS OF 256

1: 256
2: 65536
3: 16777216
4: 4294967296
5: 1099511627776
6: 281474976710656
7: 72057594037927936
8: 18446744073709551616
9: 4722366482869645213696
10: 1208925819614629174706176
11: 309485009821345068724781056
12: 79228162514264337593543950336
13: 20282409603651670423947251286016
14: 5192296858534827628530496329220096
15: 1329227995784915872903807060280344576

NORMAL TERMINATION AT LEVEL  0
LAST STATEMENT EXECUTED WAS   44

SNOBOL4 STATISTICS SUMMARY-

           1164 MS. COMPILATION TIME

           1623 MS. EXECUTION TIME

           2379 STATEMENTS EXECUTED,    1035 FAILED

            277 ARITHMETIC OPERATIONS PERFORMED

             91 PATTERN MATCHES PERFORMED

              3 REGENERATIONS OF DYNAMIC STORAGE

              0 READS PERFORMED

             17 WRITES PERFORMED

             36 K CORE USED,    3619 FREE WORDS LEFT

           0.68 MS. AVERAGE PER STATEMENT EXECUTED