An amateur’s outlook on computation and mathematics

Errors acummulate

by Brian Hayes

Published 16 June 2006

Three readers (so far) have called my attention to errors in “The Semicolon Wars,” my latest American Scientist column.

First, I referred to the programming languages ML, Haskell and Miranda as “pure” functional languages. ML doesn’t belong in that group. Although it is a language that has deep roots in the functional-programming community, ML allows assignment statements that produce side effects, violating any reasonable standard of functional “purity.”

Second, one of the example Lua programs given in the illustration on page 302 is hopelessly confused. As published, the program reads:

function factI (n)
  local accumulator = 1
  for i = 1,n do
    accum = accumulator*i
  end
  return accum
end

The definition should be:

function factI (n)
  local accumulator = 1
  for i = 1,n do
    accumulator = accumulator*i
  end
  return accumulator
end

The story of this goof may be worth telling, at least briefly. I would never trust myself to write even the smallest program correctly without testing the code. In this case I did confirm that the program compiled successfully and gave sensible-looking results, and then I did a copy-and-paste to get the text into the illustration. So what went wrong? In the tested version of the program I named the local variable “accum.” Later, I worried that this abbreviated form might be a bit cryptic to some readers, and so I decided to spell the word out in full. Surely I could make such a trivial change without retesting…?

Mea culpa. And thanks to David Hemmendinger, Steve Christensen and Kirsten Chevalier for their alert reading.

Tags for this article: computing.

Publication history

First publication: 16 June 2006

Converted to Eleventy framework: 22 April 2025

More to read...

Whales of the Web

A 2015 survey found 112 websites with at least 100,000 inbound or outbound links. Some are well known. Some you've never heard of.

Questions About Trees

Today’s Question: In a mixed-species forest, what keeps the species mixed?

Pretirement

As I kid I believed that retirement is wasted on the old, who no longer have the spunk needed to enjoy it. My views have changed as I’ve aged. So have demographic trends in employment.

We Gather Together…

At the Thanksgiving table I thought I heard someone ask, “Please pass the Covid.”