Wednesday, October 31, 2007

Haskell Substring Function

Somewhere out there a programmer is wondering, "Why doesn't Haskell seem to have a substring function? Why is this brave new world of functional programming so harsh and cruel?" (Well, maybe not the second part.) The isInfixOf function in Data.List does what you want. It isn't called "substring" because it also works with other types besides String. (See also isPrefixOf, isSuffixOf.)

I haven't seen this mentioned in Haskell tutorials so I'm posting it here.

Prelude> :m +Data.List
Prelude Data.List> "bc" `isInfixOf` "abcd"
Prelude Data.List> "zz" `isInfixOf` "abcd"

Friday, October 26, 2007

Cardboard - The Ultimate Camouflage

680 News reports that thieves concealed themselves inside a cardboard box in order to break into businesses at night and steal from them.

Detective Sergeant Reuben Stroble said anyone driving by would see the box and simply assume it was a delivery for the business.

"The concealment, I mean, no one would ever think of someone being inside a box in front of a storefront window in the middle of the night," said Det. Sgt. Stroble.

Video gamers will recognize the cardboard box camouflage as a signature trick from the Metal Gear Solid series of games. When I played those games, I thought that was a silly gimmick that was very unlikely to actually work in the real world. What's next? Will we discover that random barrels and crates really do contain power-ups?

Tuesday, October 16, 2007

Tales of Garlic

The other day we went to a local grocery store that specializes in international foods, and I got a jar of "Garlic in Oil with Herbs" from Poland. It turned out to be quite good, and so a few times a week I would open up the jar, take out one or two cloves of garlic, and eat it as a snack.

Then a few days ago, I decided to read the label more carefully, to find out the exact ingredients and the nutritional information. I was shocked to discover that according to the label the jar contains 2 servings! Eating half a jar of garlic at one sitting is considered a serving. I can't even imagine doing that.

Wednesday, October 10, 2007

I Need To Work On My Lip-Reading

The new Bionic Woman TV show has the worst-mixed soundtrack I have ever heard. The latest episode sounds approximately like this:

"BAD MUSIC, whisper, BAD MUSIC, mumble, SOUND EFFECT, whisper, SOUND EFFECT, mumble."

At least 1/4 of the spoken words were too soft in the mix to be understood. It's like the sound engineers decided, "Hey, let's turn down those lines of dialogue because they're drowning out the dumb BLOOP-BLOOP-BLOOP noise that we worked so hard on."

Planning a What?

When I saw this headline . . .

Christina Aguilera Planning Duet With Aretha Franklin

. . . for a second I thought it said they were planning a duel. Now that would have been exciting! Flintlock pistols at 40 paces, at dawn?