Really off topic now... was: Re: Face down, nine-edgefirst(wherein all is revealed)

Bob Arning arning at charm.net
Wed May 10 15:11:02 UTC 2000


On Wed, 10 May 2000 01:11:48 -0700 Dan Ingalls <Dan.Ingalls at disney.com> wrote:
>>Dan Ingalls wrote:
>>	Maybe you can tell me what this does...
>>	
>>	       INTEGER N(134)/'0','1',132*'0'/,L(2)/'(133',' A1)'/,G/133/,H/266/
>>	       DO 1 K=G,17688
>>	       IF(K.EQ.K/G*G) WRITE(6,L)(L(2),J=K,17689,H)(N((K-J)/G+2),J=G,K,G)
>>	       N(J-K+1)=2**24*MOD((N(J-K+1)-N(1)+(N(J-K)-N(1))/10)/2**23,10)+N(1)
>>	1      IF(MOD(K+1,G).EQ.0.AND.N(J/G+1).LE.N(1)) K=K-G
>>	       END
>>	
>>Gets a syntax error, of course.  If the line with the WRITE statement
>>is changed to
>>      IF(K.EQ.K/G*G) WRITE(6,L)(L(2),J=K,17689,H),(N((K-J)/G+2),J=G,K,G)	
>>.................................................^	
>>the program prints powers of two.	
>
>Aw, you just ran it!

My question is: Did you write this down from memory or did you have it written on the back of a punched card somewhere?

Cheers,
Bob

P.S. I finally got the cobwebs out of the Fortran-to-Smalltalk part of my brain and produced a reasonably faithful conversion:

'From Squeak 2.5 of August 6, 1999 on 10 May 2000 at 11:03:18 am'!
Object subclass: #Fortran
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Kernel-Methods'!

!Fortran class methodsFor: 'as yet unclassified' stamp: 'RAA 5/10/2000 11:02'!
test  "Fortran test"
	| n g h k j where what x1 stringTemp |

">>>
       INTEGER N(134)/'0','1',132*'0'/,    L(2)/'(133',' A1)'/,   G/133/,   H/266/
       DO 1 K=G,17688
       IF(K.EQ.K/G*G) WRITE(6,L)(L(2),J=K,17689,H)(N((K-J)/G+2),J=G,K,G)
       N(J-K+1)=2**24*  MOD((N(J-K+1)  -  N(1)  +  (N(J-K)-N(1))  /  10  )/2**23,   10)   +   N(1)
1      IF(MOD(K+1,G).EQ.0.AND.N(J/G+1).LE.N(1)) K=K-G
       END
<<<"

	n _ Array new: 134.
	n atAllPut: $0 asciiValue << 24.
	n at: 2 put: $1 asciiValue << 24.
	"l _ #('(133' ' A1)')."
	g _ 133.
	h _ 266.
	k _ g.
	[
		k = (k // g * g) ifTrue: [
			stringTemp _ ''.
			j _ k.
			[
				stringTemp _ stringTemp,' '.
				j _ j + h. j <= 17689
			] whileTrue.
			j _ g.
			[
				stringTemp _ stringTemp, ((n at: (((k-j) // g)+2)) >> 24) asCharacter asString.
				j _ j + g. j <= k
			] whileTrue.
			Transcript show: stringTemp; cr.
		].
		where _ j - k + 1.
		x1 _ ((n at: j - k + 1) - (n at: 1) + ( ((n at: j - k) - (n at: 1)) // 10 )) // 16r800000.
		what _ 16r1000000 *  (x1 \\ 10) +  (n at: 1).
		n 
			at: where 
			put: what.
		((k + 1 \\ g) = 0 and: [(n at: j // g + 1) <= (n at: 1)]) ifTrue: [
			k _ k - g.
		].
		k _ k + 1. k <= 17688
	] whileTrue.! !






More information about the Squeak-dev mailing list