In functional programming, is there a name for a function that takes an x and gives back a tuple (x, x)?

Viewed 38

I was wondering if there is a commonly used term for a function that turns a value into a tuple-2 in ML-family languages, or functional programming languages more generally?

let toTuple2 x = (x, x)
2 Answers

I don't know about the name of that specific function.

However, that function can be seen as a special case of a more general one:

let applyCtorToXX c x = c x x

Indeed, you can verify that toTuple2 is equivalent to applyCtorToXX (,).

In combinatory logic, or at least in how it is presented in To Mock a Mockingbird, such a function is named a "Warbler", and the symbol W is used for it (i.e. Wxy = xyy is the definition used in the book).

Looking at it from this perspective, your toTuple2 is W (,), which is the application of a warbler to the 2-tuple constructor.

Related