Way back, the municipal library had Technology books (classification P) on a little mezzanine floor, coincidentally together with English-language fiction. There were lots of interesting books there, like catalogues of all rolling stock on Swedish railways, books on Unmanned Aerial Vehicles, and also, I found, on Computer Science. At the time computers were semi-mythical beasts and programming languages had exotic and magical names (often ending in L for Language), so of course I was curious. The first book on programming I read was Ekman & Fröberg’s Lärobok i Algol (at the time of writing it was not necessary to disambiguate which version of Algol was meant). I can’t say that I understood the contents deeply, not least since I had no way of trying out the exercises—indeed I only got around to trying Algol-programming at uni many years later, and then in the form of Simula 67, designed as a superset of Algol 60. Actually, the book which really taught me programming was Kristel Siro’s Vi lär oss ADB och BASIC, and by then it was possible to get occasional access to an ABC 80 running BASIC, so I could truly try out writing programs. Incidentally, Siro’s book contained the Hailstone program (though without naming it) as well as Conway’s Life as programming exercises. I didn’t really get the point of either at the time, but have used them as test programs ever since.
Much later, a colleague was cleaning out their bookshelf, including their copy of Lärobok i Algol. I nabbed it and have kept it in my bookshelf as a memento. Reading it this much later it is noticeable how horridly badly the example code was written, but everybody was still learning at the time.
There is now a portable GNU Simula compiler which I have installed on my office laptop. Of course I have implemented the usual Hailstone program in Algol/Simula as well. When Algol was created, the designers defined a publication version of the language, which was meant to look good in scientific journals, as opposed to the caps-only, limited-character set hardware language. So, this is the publication version:
begin
integer n;
print("Input number: ");
for n := read while n > 1 do begin
n := if n / 2 = Entier(n / 2) then n / 2 else n × 3 + 1;
print(n);
end
end
No comments:
Post a Comment