Really off topic now... was: Re: Face down,
nine-edgefirst(wherein all is revealed)
Henrik Gedenryd
Henrik.Gedenryd at lucs.lu.se
Thu May 11 13:56:30 UTC 2000
Bob Arning wrote:
> P.S. I finally got the cobwebs out of the Fortran-to-Smalltalk part of my
> brain and produced a reasonably faithful conversion:
>
OK, this somewhat "shaky" quickie makes a little more sense as Smalltalk (I
wasn't meticulous about the sentinel values):
| n g i k jLast |
g _ 133.
n _ Array new: g+1 withAll: 0.
n at: 2 put: 1.
k _ g-1.
[(k_k+1) <= (g*g)] whileTrue: [
k \\ g = 0 ifTrue: [
jLast _ k+g.
Transcript cr; show: (String new: (g*g-k)//(2*g) withAll: $ ).
k//g+1 to: 2 by: -1 do: [:j | Transcript nextPutAll: (n at: j)
asString]].
i _ jLast - k + 1.
n at: i put: ((n at: i) + ((n at: i - 1) / 10) * 2 \\ 10) asInteger.
((k + 1 \\ g) = 0 and: [(n at: jLast // g + 1) <= 0])
ifTrue: [ k _ k - g]. ]
Btw Dan, it's not nice to modify the iteration variable like that! Ruined my
nice to:do: loop. (on the last line)
I still have hardly a clue of what it does.
Henrik
More information about the Squeak-dev
mailing list
|