Wednesday, March 31, 2010

LaTeX: Nested optional arguments

Latex allows you to make commands with an optional argument.  For example,


\newcommand{\Line}[1][G]{\overline{{#1}}}

Now $\Line$ will draw a G with a line above it, and $\Line[H]$ will draw
an H with a line above.  Nesting these can cause problems though.  For instance,
$\Line[\Line]$ works, but $\Line[\Line[H]]$ doesn't.  The solution is to always
wrap the optional argument in an extra set of curly braces: $\Line[{\Line[H]}]$.


Saturday, March 27, 2010

Why I love John Cheever

We got permission from a swimming instructor and swam across the lake.  We used a clumsy side stroke that still seems more serviceable to me than the overhand that is obligatory these days in those swimming pools where I spend most of my time.  The side stroke is lower class.  I've seen it once in a swimming pool, and when I asked who the swimmer was I was told he was the butler.

from The Jewels of the Cabots

Thursday, March 25, 2010

Tuesday, March 23, 2010

Sunday, March 14, 2010

latex vphantom

In LaTeX you can insert an invisible character, e.g. 'A', by using \vphantom{A}.  This is useful on Beamer slides when you are incrementally uncovering a proof.  Without the phantom letter the proof will wobble as it's uncovered.

Smackdown

From the Pittsburgh parking authority website:


Q. I utilize the Parking Authority metered lots pretty often. I noticed that the signs say, "Head in Parking Only." What is the reason for that?


A. That rule is in accordance with City of Pittsburgh Ordinance #545.03 which states "…All vehicles shall be parked head-in unless otherwise posted…"


Thus, the answer to a good question is "because I said so".   Anyone know what the real reason is?

Tuesday, March 09, 2010

Haskell profiler with -O2

I had a puzzling Haskell experience today.  I was profiling a program and was curious about a function 'new'.  The profiler said it was called 29 times, though I found that hard to believe.   I added a print statement that showed it is called twice.  After being confused for awhile, I finally realized it might be an effect due to the optimizer.  I turned optimizations off (-O2 to -O0) and it went back to 2 calls.  I don't fully understand the so-called Constant Applicative Form (CAF) centers, but I'm still surprised, even with aggressive inlining that it could occur so frequently.  Perhaps it can still count as a call if the inlined body is in a (partially evaluated) thunk.

Thursday, March 04, 2010

Aging

A nice short piece on aging, quoting Longfellow (full poem is here)

What then? Shall we sit idly down and say
The night hath come; it is no longer day?
The night hath not yet come; we are not quite
Cut off from labor by the failing light;
Something remains for us to do or dare;
Even the oldest tree some fruit may bear;
Not Oedipus Coloneus, or Greek Ode,
Or tales of pilgrims that one morning rode
Out of the gateway of the Tabard Inn,
But other something, would we but begin;
For age is opportunity no less
Than youth itself, though in another dress,
And as the evening twilight fades away
The sky is filled with stars, invisible by day.

Monday, March 01, 2010

The Capitol Hill Babysitting Coop

Interesting true story.

http://en.wikipedia.org/wiki/Capitol_Hill_Baby-Sitting_Co-op

 I first read about this in Krugman's Return of Depression Economics.  More
details are here:

http://faculty.wcas.northwestern.edu/~mwitte/B01/handouts/sweeneys.html