Saturday, January 14


in the luminous moonlight the frogs gambol
with abandon in the trampled grass

the way that lovers do

a simple engine for expressing poetic variation

The short poem above is actually the output of a routine to express variation within a block of text. Given a block of text where sets of alternative words (or strings in general) are marked off within curly brackets and separated by pipes, it randomly selects among the alternatives. Thus:

the {green|red} light
spoke to {him|her|them}
of a {tragic|distant|idyllic} {past|future}

Might become:

the red light
spoke to her
of a tragic past

Even without nested alternatives, conditionals, or any kind of branching, this is surprisingly flexible. You can take a look at the source, if you like, or reload this entry to get a new variation.

May 10, 2016 edit: Since this site is now generated statically, the poem above will only change when it's republished.

tags: topics/poem

p1k3 / 2006 / 1 / 14