Dave's Notebook

Writing Practice by David Rickmann.

Drabble: Idempotence

A drabble is a short piece of fiction 100 words in length. This is not quite that, It’s an attempt to explain a concept in exactly 100 words. This is my first go writing to this particular format, but if you’d like to see it done well (and to learn some philosophy at the same time) have a look at these.

An idempotent function is one which if run multiple times produces the same output as if it were run only once.
For example if we run the code:

x <- "idempotent"
x <- toupper(x)

we get the output: IDEMPOTENT.
if we do it again:

x <- toupper(x)

the output remains: IDEMPOTENT.
and it will remain the same no matter how many times we do it.

This can be very helpful for all sorts of reasons, like when you want to maintain the consistency of a data source or when you want to send a function over a noisy channel.