Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)
like image 475
sdgfsdh Avatar asked Dec 18 '25 02:12

sdgfsdh


1 Answers

In stack-based programming languages such as Forth, dup is a core operator that does duplicate the top stack element (not exactly a tuple though).

In Haskell, various packages provide this function under names like dup, dupe or double. Notice that two-tuples are also a core element of arrows, and dup = id &&& id.

I have not found anything specific to ML.

like image 108
Bergi Avatar answered Dec 20 '25 22:12

Bergi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!