Category Archives: Mathematics

A Perl Mystery

I’m trying to write a script to consolidate my book index, and I’ve run into a problem that’s driving me nuts. Can anyone see what’s going on here?

Here’s the relevant code:

if ($pagenumber) { #6
$numbers = $_;
$i = 0;

foreach (@numberarray) {
$numberarray[$i] = “”;
$i = $i + 1;
} # End foreach
$i = 0;

foreach (@sorted_numbers) {
$sorted_numbers[$i] = “”;
$i = $i + 1;
} # End foreach
$i = 0;

print $DEBUG2 “\$numbers is $numbers before entering while.\n”;

while ($numbers =~ /(\d+)(.*)/) {
print $DEBUG2 “\$1 is |$1|, \$pagenumber is |$pagenumber|.\n”;
if (!($1 eq $pagenumber)) {
$numberarray[$i] = $1;
$i = $i + 1;
} # End if
print $DEBUG2 “In while loop, \$numberarray[$i] is $numberarray[$i].\n”;
$numbers = $2;
print $DEBUG2 “Point 10: \$numbers is $numbers, \$i is |$i|.\n”;
} # End while
$numberarray[$i] = $pagenumber;
print $DEBUG2 “After while loop, \$numberarray[$i] is |$numberarray[$i]|, \$sorted_numbers[$i] is |$sorted_numbers[$i]|\n”;
@sorted_numbers = sort { $a <=> $b } @numberarray;
@numberarray = @sorted_numbers;
print $DEBUG2 “After sort, \$sorted_numbers[$i] is |$sorted_numbers[$i]|.\n”;

print $DEBUG2 “After sort \@numberarray is @numberarray, \$numberarray[$i] is $numberarray[$i].\n”;
$i = 0;
print $DEBUG2 “About to enter foreach (\@sorted_numbers).\n”;
$next = $i + 1; #Just for diagnostics
print $DEBUG2 “Before foreach, \$totalname is |$totalname|, \$numberarray[$i] is |$numberarray[$next]|, \$numberarray[$next] is |$numberarray[$i+1]|.\n”;
foreach (@numberarray) {
print $DEBUG2 “Got inside the loop.\n”;
print $DEBUG2 “**\$totalname is $totalname for \$i = $i.\n”;
$totalname = $totalname . ” ” . “$numberarray[$i],”;
$i = $i + 1;
}
print $DEBUG2 “Before chop condition, \$totalname is $totalname.\n”;
if ($totalname =~ /.*\,$/) {chop $totalname}
print $DEBUG2 “After chop condition, \$totalname is $totalname.\n”;

And here’s the debug output, for two different cases. One works, the other doesn’t and I can’t figure out what’s happening, but whatever it is, it seems to be happening in the sort. They should both give similar output — the name and a single page number, but as you can see, they don’t.

CASE 1

$numbers is Michael Adams 19, before entering while.
$1 is |19|, $pagenumber is |19|.
In while loop, $numberarray[0] is .
Point 10: $numbers is ,, $i is |0|.
After while loop, $numberarray[0] is |19|, $sorted_numbers[0] is ||
$sorted_numbers[0] is |19|.
after exiting @numberarray is 19, $numberarray[0] is 19.
About to enter foreach (@sorted_numbers).
Before foreach, $totalname is |Adams, Michael|, $numberarray[0] is ||, $numberarray[1] is ||.
Got inside the loop.
**$totalname is Adams, Michael for $i = 0.
Before chop condition, $totalname is Adams, Michael 19,.
After chop condition, $totalname is Adams, Michael 19.

CASE 2

$numbers is Bill Anders 26, before entering while.
$1 is |26|, $pagenumber is |26|.
In while loop, $numberarray[0] is .
Point 10: $numbers is ,, $i is |0|.
After while loop, $numberarray[0] is |26|, $sorted_numbers[0] is ||
$sorted_numbers[0] is ||.
after exiting @numberarray is 26, $numberarray[0] is .
About to enter foreach (@sorted_numbers).
Before foreach, $totalname is |Anders, Bill|, $numberarray[0] is ||, $numberarray[1] is ||.
Got inside the loop.
**$totalname is Anders, Bill for $i = 0.
Got inside the loop.
**$totalname is Anders, Bill , for $i = 1.
Got inside the loop.
**$totalname is Anders, Bill , , for $i = 2.
Before chop condition, $totalname is Anders, Bill , , 26,.
After chop condition, $totalname is Anders, Bill , , 26.

The Climate Models

…are getting worse than we thought:

The author hypothesizes the reasons for this are that attempts in the latest generation of models to reproduce observed changes in Arctic sea ice are causing “significant and widening discrepancy between the modeled and observed warming rates outside of the Arctic,” i.e. they have improved Arctic simulation at the expense of poorly simulating the rest of the globe.

It continues to amaze me that so many supposedly smart people take this junk science seriously. You know what this stuff looks more and more like to me? Epicycles.

Fifty To One

A new climate education project:

50 to 1 cuts across all the noise and fury surrounding the ‘climate debate’ and gets right to the point: Even if the IPCC is right, and even if climate change IS happening and it IS caused by man, we are STILL better off adapting to it as it happens than we are trying to ‘stop’ it. ‘Action’ is 50 times more expensive than ‘adaptation’, and that’s a conclusion which is derived directly from the IPCC’s own predictions and formulae!

Here’s a link to the Indiegogo site.

Being Normal

Thoughts from Sarah Hoyt:

You see, the human desire to mimic and fit in is one of our strongest instincts. We are social apes. And we take our cues from stories, whether those stories unroll before our eyes, are in a sacred book, are passed down in the culture, or are poured at us in books and TV.

Now, here’s the thing – the Marxists understand this all too well. A few of you, before, when I called them a religion (there is no such thing as a secular religion, btw. Believing in afterlife is not needed for a religion. If I’m informed correctly some older forms of Judaism are at least mum on the subject. Communism is a mystery religion, relying on “something happens” to make their paradise come about right here on Earth. To their credit they work towards the ‘something” that is to transform man. To their lack of credit, both their goal and their methods are repugnant.) But they are. They have created their fantastical past paradise – the supposedly communitarian past/female dominant option not included, though they let the feminists run with it – their fall from grace – the introduction of private property – their sin – “greed”, meaning wish for personal improvement in circumstances – and their hope of paradise – the emergence of the homo Sovieticus, though I suppose they don’t call it that now. After that, of course, it would be the return to the communitarian paradise.

(They fail to understand that their communitarian paradise is actually a h*ll of individuals being treated as things, and that, because the collective can’t ever decide things as a collective, an individual ends up taking control. Which takes us right back to feudalism. But let that pass. And having told a commenter not to trust enemies of a religion as information on it, I’m bound to say I’m not. I was taught by true believers. It just didn’t take.)

I’ve always found normality to be highly overrated, myself. It’s not normal, for instance, to be much smarter than average, by definition. I’m always amused when people complain about gays wanting to “normalize” their behavior (which is clearly abnormal), as though there is a moral component to statistics.