Oops. Looks like my comment could be interpreted 2 ways.
Meant: best to write extremely clear, even simplistic, example code -- even if it's less than optimum.
If your reader is experienced s/he'll figure out the elegant method once s/he's gotten over the impediment that generated the question in the first place.
Sorry if you took my comments otherwise.