Two Sundays ago, I walked with my friend Hendrik Hilberdink along
the Oxford canal and into Kidlington. As we
wandered along Kidlington's stunningly tedious main street, I pointed out
the
gym that I use. Oxford prices being what they are, it's cheaper than
ones nearer home.
But I haven't visited it recently, because I reckon
I've expended enough calories letting my fingers
do the walking. They've been typing recursive list
decompositions and base cases in Prolog, pounding out
the same old boring boilerplate code over and over and
over again. In this essay, I'll show you how to eliminate
the boilerplate by using higher-order programming:
functions that take other functions as arguments; or in Prolog,
predicates that take other predicates as arguments.
I have experimented with it to share code between the
"span" and "span_count" patterns that I talked about
in
Snobol
Patterns in Prolog II: Span with Count.