Chip's Quips
A tiny spark of wit for a highly flammable world

Regex Anglorum

July 29th, 2010 9:33:18 am pst by Sterling Camden

As I was walking the dogs this morning along our usual route, Halley and Harry stopped to sniff a greasy spot in the road which had been occupied the day before by an unlucky squirrel. “Hmm… some other scavenger must have cleaned it up,” I thought, then corrected myself: “scavenger, or scavengers.”

English has no specific form to indicate “one or more” — nouns can be singular or plural, not (usually) inclusive of both. The more advanced syntax for Regular Expressions uses ‘+’ to indicate this set. I propose that we adopt this into English, as in “some other scavenger+ must have cleaned it up.” That would naturally cause some consternation for present tense verbs when one of these nouns is the subject, but we could use the same ending there: “The scavenger+ eat+ all the dead squirrels.” (I never understood why the ‘s’ occurs on singular verbs instead of on the plural).

Of course, in a regex /scavenger+/ would mean “scavenge” followed by one or more “r”s. We’d need to say /(scavenger)+/ instead.

Wait, that isn’t right either — that just indicates one or more occurrences of the word scavenger. Not one or more scavengers. Abstract symbols are a bit foreign to Regexen, but they do exist in the more advanced syntaxen. Take Ruby’s, for example:

/(#{scavenger})+/

Now that says,”one or more of what the word ‘scavenger’ represents.”

The English language is not nearly so rigorous. Take the plural, for instance. You might think that a regex equivalent for “scavengers” would be:

/(#{scavenger}){2,}/

That says, “two or more of what the word ‘scavenger’ represents.”

In English, though, we also use the plural form for zero. “Yes, we have no bananas.” Let’s add that ambiguity to our expression:

/((#{banana}){2,})*/

The star says, “zero or more of the previous pattern” — so this accurately represents the idea of “two or more bananas, or none at all”.

Of course, in English I could use the singular form for zero as well: “Yes, we have no banana.” That would carry the connotation that we could have exactly one banana, but we don’t. We’re going to need a smarter squirrel.

Posted in Out of Nowhere | 14 Comments » RSS 2.0

Chipping the web: July 28th

July 28th, 2010 3:00:25 pm pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0

Chipping the web: July 24th

July 24th, 2010 1:00:42 pm pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0

Chipping the web: July 22nd

July 22nd, 2010 11:00:27 am pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0

Chipping the web: July 18th

July 18th, 2010 10:00:41 am pst by Sterling Camden

Chipping the web

Posted in Share the Love | 8 Comments » RSS 2.0

Chipping the web: July 13th

July 13th, 2010 1:00:13 pm pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0

Chipping the web: July 10th

July 10th, 2010 2:01:15 pm pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0

Chipping the web: July 9th

July 9th, 2010 9:01:13 am pst by Sterling Camden

Chipping the web

Posted in Share the Love | 2 Comments » RSS 2.0

Camel maneuver, or taken for a ride?

July 7th, 2010 11:45:19 am pst by Sterling Camden

I glanced at my watch as I weaved the cart between old ladies and children. Right on schedule — ten minutes to get checked out and drive over to pick up my daughter. I scanned the checkout lines until I found a conveyor with some empty space — the checker was just scanning the last item. I veered in behind the previous shopper, lifted my cargo onto the belt, and whipped out my debit card.

“$54.50,” said the checkout lady to the slightly overweight, very young lady — too young to be juggling one child in her arms with another in a stroller.

“Oh wait,” she said, and began to pull items out to be removed from her total: first the cola, then the cupcakes. Yeah, honey, you don’t need those. Couldn’t you keep a running total while you were shopping? Oh yeah, I guess you were distracted by all your offspring. Now I’ll probably be late for my daughter, thanks to your lack of planning.

“$47.80.” Still not enough. Reluctantly, a package of ground beef and some broccoli left the ensemble. Doesn’t she realize that she’s holding me up? Then, a pang of guilt. Look at me, in such a hurry to checkout with my case of champagne — so I won’t be a few minutes late picking up my daughter from ballet. I have it so hard. And here she is, just trying to make ends meet.

But why not? (says the capitalist in me) I’ve worked hard to get where I am and to be able to enjoy just a few of the finer things. And what series of bad decisions led this woman to her present misfortune? Alone with children at such an early age — she probably doesn’t have a job.

Today’s economy. Perhaps she did have a job that recently evaporated. She might be a Navy wife, with a husband on extended duty. It doesn’t take much to upset most people’s finances. In the recent mortagage crisis, we were lucky — one additional bad credit decision could have spelled the loss of our home.

In fact, most of what I have accomplished in my career and finances resulted from making a good choice when a bad one seemed just as good at the time. Call it luck. And I hate to see her have to give up the beef and broccoli — that’s good food.

So I leaned over to her, handed her a $20 bill, and said quietly, “Maybe this will help.”

Her eyes widened with surprised joy, then turned aside in shame. “No, I couldn’t. Thank you very much, though.”

“C’mon,” I said. “You’ve got a family to feed, right? Just take it.”

She looked back hopefully, trying to make out in my eyes whether it really would be OK to accept.

“Oh, thank you! Nobody’s ever done that for me before. Thank you so much.”

“Don’t worry about it.”

I noticed with some satisfaction that she took back the beef and broccoli, and left out the cupcakes and soda. She offered me the change, but I waved it back at her. She thanked me again, gathered up her groceries and her children, and hurried toward the door. As the checkout lady began to scan my bottles, she called to one of her assistants in a voice that was calculated to get her attention without alerting anyone else, “Check her.”

In response to my puzzled expression, she explained, “That one’s in here a lot, and things seem to go missing.”

I didn’t know what to think. Suddenly, my first opinion of her seemed confirmed — even augmented. Or was the checkout lady unduly suspicious of her because she was poor — maybe also resentful of the extra time she took checking out? Had I aided a minor criminal? Would my act of kindness encourage her to reform?

No matter. I had achieved my purpose: getting her through checkout, and out of my way.

Tags: ,

Posted in Out of Nowhere | 6 Comments » RSS 2.0

Chipping the web: July 3rd

July 3rd, 2010 4:00:02 pm pst by Sterling Camden

Chipping the web

Posted in Share the Love | No Comments » RSS 2.0