[Question]
  [
Given an positive even integer \$ n \$, output the set of "ways to pair up" the set \$ [1, n] \$. For example, with \$ n = 4 \$, we can pair up the set \$ \{1, 2, 3, 4\} \$ in these ways:
* \$ \{\{1, 2\}, \{3, 4\}\} \$
* \$ \{\{1, 3\}, \{2, 4\}\} \$
* \$ \{\{1, 4\}, \{2, 3\}\} \$
This can more formally be described as the set of sets of pairs of integers such that those pairs exactly cover the set \$ [1, n] \$.
Note that because we're dealing with sets here, the order of the pairs is irrelevant. For example, \$ \{\{1, 2\}, \{3, 4\}\} \$ is considered the same as \$ \{\{3, 4\},\{2, 1\}\} \$.
For the same reason, the order of your output does not matter. However, your output may not contain duplicates.
* If you want, you can choose to operate on the set \$ [0, n) \$ instead of \$ [1, n] \$
* If you want, you can choose to take the integer \$ \frac n 2 \$ as input, instead of \$ n \$
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins.
## Test cases
```
2 -> {{{1, 2}}}
4 -> {{{1, 2}, {3, 4}}, {{1, 3}, {2, 4}}, {{1, 4}, {2, 3}}}
6 -> {{{1, 2}, {3, 4}, {5, 6}}, {{1, 2}, {3, 5}, {4, 6}}, {{1, 2}, {3, 6}, {4, 5}}, {{1, 3}, {2, 4}, {5, 6}}, {{1, 3}, {2, 5}, {4, 6}}, {{1, 3}, {2, 6}, {4, 5}}, {{1, 4}, {2, 3}, {5, 6}}, {{1, 4}, {2, 5}, {3, 6}}, {{1, 4}, {2, 6}, {3, 5}}, {{1, 5}, {2, 3}, {4, 6}}, {{1, 5}, {2, 4}, {3, 6}}, {{1, 5}, {2, 6}, {3, 4}}, {{1, 6}, {2, 3}, {4, 5}}, {{1, 6}, {2, 4}, {3, 5}}, {{1, 6}, {2, 5}, {3, 4}}}
8 -> {{{1, 2}, {3, 4}, {5, 6}, {7, 8}}, {{1, 2}, {3, 4}, {5, 7}, {6, 8}}, {{1, 2}, {3, 4}, {5, 8}, {6, 7}}, {{1, 2}, {3, 5}, {4, 6}, {7, 8}}, {{1, 2}, {3, 5}, {4, 7}, {6, 8}}, {{1, 2}, {3, 5}, {4, 8}, {6, 7}}, {{1, 2}, {3, 6}, {4, 5}, {7, 8}}, {{1, 2}, {3, 6}, {4, 7}, {5, 8}}, {{1, 2}, {3, 6}, {4, 8}, {5, 7}}, {{1, 2}, {3, 7}, {4, 5}, {6, 8}}, {{1, 2}, {3, 7}, {4, 6}, {5, 8}}, {{1, 2}, {3, 7}, {4, 8}, {5, 6}}, {{1, 2}, {3, 8}, {4, 5}, {6, 7}}, {{1, 2}, {3, 8}, {4, 6}, {5, 7}}, {{1, 2}, {3, 8}, {4, 7}, {5, 6}}, {{1, 3}, {2, 4}, {5, 6}, {7, 8}}, {{1, 3}, {2, 4}, {5, 7}, {6, 8}}, {{1, 3}, {2, 4}, {5, 8}, {6, 7}}, {{1, 3}, {2, 5}, {4, 6}, {7, 8}}, {{1, 3}, {2, 5}, {4, 7}, {6, 8}}, {{1, 3}, {2, 5}, {4, 8}, {6, 7}}, {{1, 3}, {2, 6}, {4, 5}, {7, 8}}, {{1, 3}, {2, 6}, {4, 7}, {5, 8}}, {{1, 3}, {2, 6}, {4, 8}, {5, 7}}, {{1, 3}, {2, 7}, {4, 5}, {6, 8}}, {{1, 3}, {2, 7}, {4, 6}, {5, 8}}, {{1, 3}, {2, 7}, {4, 8}, {5, 6}}, {{1, 3}, {2, 8}, {4, 5}, {6, 7}}, {{1, 3}, {2, 8}, {4, 6}, {5, 7}}, {{1, 3}, {2, 8}, {4, 7}, {5, 6}}, {{1, 4}, {2, 3}, {5, 6}, {7, 8}}, {{1, 4}, {2, 3}, {5, 7}, {6, 8}}, {{1, 4}, {2, 3}, {5, 8}, {6, 7}}, {{1, 4}, {2, 5}, {3, 6}, {7, 8}}, {{1, 4}, {2, 5}, {3, 7}, {6, 8}}, {{1, 4}, {2, 5}, {3, 8}, {6, 7}}, {{1, 4}, {2, 6}, {3, 5}, {7, 8}}, {{1, 4}, {2, 6}, {3, 7}, {5, 8}}, {{1, 4}, {2, 6}, {3, 8}, {5, 7}}, {{1, 4}, {2, 7}, {3, 5}, {6, 8}}, {{1, 4}, {2, 7}, {3, 6}, {5, 8}}, {{1, 4}, {2, 7}, {3, 8}, {5, 6}}, {{1, 4}, {2, 8}, {3, 5}, {6, 7}}, {{1, 4}, {2, 8}, {3, 6}, {5, 7}}, {{1, 4}, {2, 8}, {3, 7}, {5, 6}}, {{1, 5}, {2, 3}, {4, 6}, {7, 8}}, {{1, 5}, {2, 3}, {4, 7}, {6, 8}}, {{1, 5}, {2, 3}, {4, 8}, {6, 7}}, {{1, 5}, {2, 4}, {3, 6}, {7, 8}}, {{1, 5}, {2, 4}, {3, 7}, {6, 8}}, {{1, 5}, {2, 4}, {3, 8}, {6, 7}}, {{1, 5}, {2, 6}, {3, 4}, {7, 8}}, {{1, 5}, {2, 6}, {3, 7}, {4, 8}}, {{1, 5}, {2, 6}, {3, 8}, {4, 7}}, {{1, 5}, {2, 7}, {3, 4}, {6, 8}}, {{1, 5}, {2, 7}, {3, 6}, {4, 8}}, {{1, 5}, {2, 7}, {3, 8}, {4, 6}}, {{1, 5}, {2, 8}, {3, 4}, {6, 7}}, {{1, 5}, {2, 8}, {3, 6}, {4, 7}}, {{1, 5}, {2, 8}, {3, 7}, {4, 6}}, {{1, 6}, {2, 3}, {4, 5}, {7, 8}}, {{1, 6}, {2, 3}, {4, 7}, {5, 8}}, {{1, 6}, {2, 3}, {4, 8}, {5, 7}}, {{1, 6}, {2, 4}, {3, 5}, {7, 8}}, {{1, 6}, {2, 4}, {3, 7}, {5, 8}}, {{1, 6}, {2, 4}, {3, 8}, {5, 7}}, {{1, 6}, {2, 5}, {3, 4}, {7, 8}}, {{1, 6}, {2, 5}, {3, 7}, {4, 8}}, {{1, 6}, {2, 5}, {3, 8}, {4, 7}}, {{1, 6}, {2, 7}, {3, 4}, {5, 8}}, {{1, 6}, {2, 7}, {3, 5}, {4, 8}}, {{1, 6}, {2, 7}, {3, 8}, {4, 5}}, {{1, 6}, {2, 8}, {3, 4}, {5, 7}}, {{1, 6}, {2, 8}, {3, 5}, {4, 7}}, {{1, 6}, {2, 8}, {3, 7}, {4, 5}}, {{1, 7}, {2, 3}, {4, 5}, {6, 8}}, {{1, 7}, {2, 3}, {4, 6}, {5, 8}}, {{1, 7}, {2, 3}, {4, 8}, {5, 6}}, {{1, 7}, {2, 4}, {3, 5}, {6, 8}}, {{1, 7}, {2, 4}, {3, 6}, {5, 8}}, {{1, 7}, {2, 4}, {3, 8}, {5, 6}}, {{1, 7}, {2, 5}, {3, 4}, {6, 8}}, {{1, 7}, {2, 5}, {3, 6}, {4, 8}}, {{1, 7}, {2, 5}, {3, 8}, {4, 6}}, {{1, 7}, {2, 6}, {3, 4}, {5, 8}}, {{1, 7}, {2, 6}, {3, 5}, {4, 8}}, {{1, 7}, {2, 6}, {3, 8}, {4, 5}}, {{1, 7}, {2, 8}, {3, 4}, {5, 6}}, {{1, 7}, {2, 8}, {3, 5}, {4, 6}}, {{1, 7}, {2, 8}, {3, 6}, {4, 5}}, {{1, 8}, {2, 3}, {4, 5}, {6, 7}}, {{1, 8}, {2, 3}, {4, 6}, {5, 7}}, {{1, 8}, {2, 3}, {4, 7}, {5, 6}}, {{1, 8}, {2, 4}, {3, 5}, {6, 7}}, {{1, 8}, {2, 4}, {3, 6}, {5, 7}}, {{1, 8}, {2, 4}, {3, 7}, {5, 6}}, {{1, 8}, {2, 5}, {3, 4}, {6, 7}}, {{1, 8}, {2, 5}, {3, 6}, {4, 7}}, {{1, 8}, {2, 5}, {3, 7}, {4, 6}}, {{1, 8}, {2, 6}, {3, 4}, {5, 7}}, {{1, 8}, {2, 6}, {3, 5}, {4, 7}}, {{1, 8}, {2, 6}, {3, 7}, {4, 5}}, {{1, 8}, {2, 7}, {3, 4}, {5, 6}}, {{1, 8}, {2, 7}, {3, 5}, {4, 6}}, {{1, 8}, {2, 7}, {3, 6}, {4, 5}}}
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
≈í!Hƒäƒ†‚Ç¨·π¢‚Ç¨Q
```
[Try it online!](https://tio.run/##fZc9ThxBEIVzn2IskVgaCbHT9XMEp4RotaETiws4IIAEiZATICdOfAEkMuAg@CLjWZjeberV6w12Z7u@6VfTb6u69@ePy8tf8/x6//X7y93Lw7@bv2@Pv5f38/n59uNq/379dLg@ufry/Of028U8bzfjsN1uz8Zhs1tey5dyHFiupnEo78P7kWl/sWlHyjoyrTcr3rx8yjjo4ZYakVUMI7pGJBGOs9UIzlYjONsx6ThbaWebsogesq8RaWf7lIG0WU9ZRGGJNcwmECmQgYasy2qGczOWTxsHh6WvhK1mcsJXwjrGMpVKcJVKcJWjrUxFWxXpEX546khYq5Jmau3TSo9wWgoeVIwSSjP18LTaKZ64YpFAXyKBvmAhMhXufiS4Cnc/Euh@JND9SnD3I6FUhbtfCe5@JJRmyt3HZhdXLBLoSyTQF2ycTEXaqtAewVW07RKpirYq0iPQ/dI6N2XuR0KpigUV9MWDilFCaaYenlY7m1NcsUigL5FAX3CjYyqFuh8JrqLtTpSqKHReRhzrJhLWqqSZGuwijHB6NPCgYpRQmqnDTsQPE3HFNHNfegTWCx5MmEqhVamZ@6mKUPc16zClR6D7mrmfZmpwUmGE06Ocw6mLEUIzdTipVMIy9z/9ki3rDtIjsI9Z5n6qUmi3NOI@qgitSst2oNIjsCot6zBppkrdN9Jh0Benf5GMuM8J/JPjxH2jBO4vTrqDAlHoLubEfU5wFaHd0on7nMBu6cR9o4RQFaVV6aTDKCWEZmro/m73Hw "Jelly ‚Äì Try It Online")
```
≈í!           All permutations of [1 .. n].
  H          Halve each number in each permutation
   ƒä         rounding up,
    ƒ†‚Ç¨       group indices of equal values in each,
      ·π¢‚Ç¨     sort each index-grouping,
        Q    and uniquify.
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `R`, 9 bytes
```
·πñ∆õ2·∫ávss;U
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJSUCIsIiIsIuG5lsabMuG6h3ZzcztVIiwiIiwiNCJd)
Takes \$n\$ as input.
```
·πñ∆õ2·∫ávss;U
·πñ         # Permutations of [1, n]
 ∆õ        # For each:
  2·∫á      #  Split into chunks of length 2
    vs    #  Sort each
      s   #  Sort
       ;  # Close map
        U # Uniquify
```
# [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes
```
d…æ2·∏ã·∏ã'f√ûu
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJQIiwiIiwiZMm+MuG4i+G4iydmw551IiwiIiwiMiJd)
Port of caird's Jelly answer, takes \$\frac{n}{2}\$ as input.
```
d…æ2·∏ã·∏ã'f√ûu
d         # Double, n √ó 2
 …æ        # Range [1, that]
  2·∏ã      # Combinations without replacement of length 2
    ·∏ã     # Combinations without replacement of length {input}
     '    # Filter for:
      f√ûu #  Is it unique after flattening?
```
[Answer]
# [Curry (PAKCS)](https://www.informatik.uni-kiel.de/%7Epakcs/), 44 bytes
```
f n=g[1..n]
g[]=[]
g(a:b++c:d)=(a,c):g(b++d)
```
[Try it online!](https://tio.run/##Sy4tKqrULUjMTi7@/z9NIc82PdpQTy8vlis9OtY2GkhpJFolaWsnW6Vo2mok6iRrWqVrAPkpmv9zEzPzFGwV0hTM/gMA "Curry (PAKCS) ‚Äì Try It Online")
This is a non-deterministic function whose return values are the all the ouputs.
[Answer]
# [Python](https://www.python.org), 84 bytes
```
def f(n,o={}):(n>sum(1>o[K]!=f(n-1,o|{K:n})for K in o)==f(n-1,o|{n:0}))==n==print(o)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3Q1JS0xTSNPJ08m2razWtNPLsiktzNQzt8qO9YxVtgRK6hjr5NdXeVnm1mmn5RQreCpl5CvmatgipPCuDWk2gQJ6tbUFRZl6JRr4mxOx1aRpGmlxpGiYgwgwqCLMYAA)
Using dictionaries instead of sets.
### Previous [Python](https://www.python.org), 91 bytes
```
def f(n,*o):[f(n-1,*{*o}^{(K,n),K})for K in o if-1*K][n-1:]or f(n-1,*o,n)if n else print(o)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3o1NS0xTSNPJ0tPI1raKBDF1DHa1qrfzauGoNb508TR3vWs20_CIFb4XMPIV8hcw0XUMt79hooDKrWKAwVEM-UGVmmkKeQmpOcapCQVFmXolGvibEinVpGkaaXGkaJiDCDCoIsx8A)
Takes `n` and prints all unique pairings.
How?
Counting down `n` either add the current value to an existing unfinished pair or start a new pair. One can check that this visits each pairing exactly once.
[Answer]
# [Python](https://www.python.org), ~~101~~ ~~98~~ 94 bytes
```
def f(r,*x):
 if r:a,*r=r;[f({*r}-{b},*x,(a,b))for b in r]
 else:print(x)
def g(n):f(range(n))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY341JS0xTSNIp0tCo0rbgUMtMUiqwSdbSKbIuso9M0qrWKanWrk2qBsjoaiTpJmppp-UUKSQqZeQpFsVwKqTnFqVYFRZl5JRoVmlwgk9I18jStgMYl5qWnApmaEFuWpGuYQZkwiwE)
Takes \$n\$ as input, operates on the set \$[0,n)\$, prints tuples of tuples.
---
-3 bytes from @Unrelated String by using splatting instead of passing in an array  
-4 bytes from @pxeger by using list comprehension
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 52 bytes
```
Map[Union,{#~Partition~2&/@Permutations@Range@#},3]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73zexIDo0LzM/T6dauS4gsagkswTIqTNS03cISC3KLS1JBPGLHYIS89JTHZRrdYxj1f4HFGXmlUQr69qlOSjHqtUFJyfm1VVzGelwmehwmelwWXDV/gcA "Wolfram Language (Mathematica) ‚Äì Try It Online")
Input \$n\$. Returns a list of pair-lists, wrapped in a list.
```
Map[Union,{#~Partition~2&/@Permutations@Range@#},3]&
                           Permutations@Range@#     permutations
           #~Partition~2&/@                           pair
          {                                    }        increase depth by 1
Map[Union,                                      ,3]     unique all
```
Since `Map` does not apply at level `0` by default, wrapping the output with `{ }` saves 2 bytes over including that level explicitly, e.g. with `Map[Union,...,{0,2}]` or `u@Map[u=Union,...,2]`.
[-1](https://tio.run/##y00syUjNTSzJTE78n2b73zexIDo0LzM/T0e5LiCxqCSzBMiuM1LTdwhILcotLUkE8YsdghLz0lMdlNV1jGPV/gcUZeaVRCvr2qU5KMeq1QUnJ@bVVXMZ6XCZ6HCZ6XBZcNX@BwA) if output wrapped in a `Derivative[1]` rather than a `List` is acceptable.
[Answer]
# [Haskell](https://www.haskell.org), 60 bytes
```
f n=g[1..n]
g[]=[[]]
g(h:t)=[(h,e):x|e<-t,x<-g$filter(e/=)t]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ8GCpaUlaboWN23SFPJs06MN9fTyYrnSo2Nto6NjgQyNDKsSTdtojQydVE2rippUG90SnQob3XSVtMycktQijVR9W82SWKgZxrmJmXkKtgop-VwKCgVFmXklCioKaQpGKDwTFJ4ZRCvMGQA)
Not sure if it can be improved.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
L≈ìŒµ2√¥‚Ç¨{{}√™
```
[Try it online](https://tio.run/##yy9OTMpM/f/f5@jkc1uNDm951LSmurr28Kr//00A) or [verify all test cases](https://tio.run/##AS4A0f9vc2FiaWX/OMOFw4jCpnZ5PyIg4oaSICI/ef9MxZPOtTLDtOKCrHt7fcOq/yz/).
Alternative with the same byte-count (thanks to *@CommandMaster*):
```
L¬©.√Ü√¶ íÀú{¬ÆQ
```
[Try it online](https://tio.run/##ARsA5P9vc2FiaWX//0zCqS7DhsOmypLLnHvCrlH//zQ) or [verify all test cases](https://tio.run/##AS8A0P9vc2FiaWX/OMOFw4jCpnZ5PyIg4oaSICI/ef9Mwqkuw4bDpsqSy5x7wq5R/30s/w).
**Explanation:**
```
L          # Push a list in the range [1, (implicit) input]
 ≈ì         # Get all permutations of this list
  Œµ        # Map over each permutation:
   2√¥      #  Split it into parts of size 2
     ‚Ç¨{    #  Sort each inner pair
       {   #  Then sort all pairs
  }√™       # After the map: sort and uniquify the list of lists of pairs
           # (which in this case is faster than just an uniquify)
           # (after which the result is output implicitly)
L          # Push a list in the range [1, (implicit) input]
 ¬©         # Store this list in variable `¬Æ` (without popping)
  .√Ü       # Create all sorted unique pairs of this list
    √¶      # Get the powerset of this list of pairs
      í     # Filter each inner list of pairs by:
      Àú    #  Flatten it to a single list
       {   #  Sort it
        ¬ÆQ #  Check if it's equal to list [1,input] from variable `¬Æ`
           # (after which the filtered list is output implicitly)
```
[Answer]
# [R](https://www.r-project.org), ~~95~~ 92 bytes
```
f=\(n,v=1:n,a={},`+`=list)`if`(n,sapply(seq(v)[-1],\(i,b=c(1,i))f(n-2,v[-b],c(+v[b],a))),+a)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=Tc1BCgIhFIDh67yHz4UtIgJPokM6Q4YgYmrCEJ2kjS1atusy3aaBadHqX3yL__7I_WVDOCTrs4-nIp-X6vjuo53UEKlJsY9k5fVGhhkZfKlovDMLFZtSmKEcz9BQcTGQBk-jnECQR3QQ-Yaa4uNAE7CmllpEJGZxfbxLzfD_hi3-qPe1Xw)
[Answer]
# [Factor](https://factorcode.org/) + `math.combinatorics`, 75 bytes
```
[ iota [ natural-sort ] dup '[ 2 group _ map @ ] map-permutations members ]
```
[Try it online!](https://tio.run/##HY2xDsIwDET3fsVtTHRACCFY2BALC2KqEEqD20a0SXCcoUJ8e3E7WTq/u9cYK4Gn@@1yPR8wGOlKNr6lhBRYnG/xJvbUo@ERLYcc5yzRJ5O3Si0NG4baeaNDzmqRJCEyiYyRnRe4gGNRfLHBFjvs8ZsqzcSggpYym349y/DAK0esKgUXE546H3HSh951JB6yGHHBq5eGmjjhMc1IhbIs4Xslydhu@gM "Factor ‚Äì Try It Online")
Uses \$[0..n)\$ instead of \$[1..n]\$ to save a byte.
This would be more clearly written as
```
[ iota [ 2 group [ natural-sort ] map natural-sort ] map-permutations members ]
```
However, `natural-sort` is so long it's shorter to stick in a quotation, dup it, and fry them into the `map-permutations` quotation appropriately. I'll explain the second version since the first version constructs it.
* `iota` Get an integer range from 0 inclusive to the input exclusive.
* `[ ... ] map-permutations` Apply `[ ... ]` to each permutation of the above range and collect the results in a new sequence.
* `2 group` Group a sequence into pairs. e.g. `{ 1 2 3 4 }` -> `{ { 1 2 } { 3 4 } }`.
* `[ natural-sort ] map` Sort each pair.
* `natural-sort` Sort the sequence of pairs.
* `members` Take the unique elements of a sequence.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
≈íc≈ìcHFQ∆ë$∆á
```
[Try it online!](https://tio.run/##ATUAyv9qZWxsef//xZJjxZNjSEZRxpEkxof/LMOHxZLhuZgkSylq4oG@wrbCtv//MiwgNCwgNiwgOA "Jelly ‚Äì Try It Online")
## How it works
```
≈íc≈ìcHFQ∆ë$∆á - Main link. Takes n on the left
≈íc         - Unordered pairs
    H      - Halve
  ≈ìc       - Combinations without replacement of length n/2
        $∆á - Keep those for which the following is true:
     F     -   When flattened,
       ∆ë   -   the list is unchanged after
      Q    -   deduplication
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 10 bytes
```
um»ØOmOC2P·∏£
```
[Try it online!](https://tio.run/##yygtzv7/vzT3xHr/XH9no4CHOxb////fBAA "Husk ‚Äì Try It Online")
Range (`·∏£`) => permutations (`P`) => map (`m`) 3 functions (`»Ø`) over each: cut into sublists of 2 (`C2`), sort each sublist (`mO`), and sort each (`O`) => finally keep only unique elements (`u`).
[Answer]
# [Python](https://www.python.org), 124 bytes
*Thanks to user `Steffan` for -4 bytes.*
Takes the integer \$ \frac n 2 \$ as input and operates on the set \$ [0, n) \$. Outputs a set of tuples of tuples.
```
lambda n:{t for t in c(sorted(c(range(2*n),2)),n)if len(sum(t,()))==len({*sum(t,())})}
from itertools import*;c=combinations
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PY5LDoJAEET3nKJ3dBMISlwYDJ7EDb_RSZgeMjQLg5zEDYnRO3kbIRBXlaqk6tXz097lZnl6qezy7kVFx--jyU1R5cDpIKCsAwHNUGJnndQVluhyvtaYBExhQhQyaQVNzdj1BiVEIsqyxQ_BPxlp9JSzBrTUTqxtOtCmnQeDU5mV1hSac9GWu-3DYeHywt1g4X43w1IPoHWaBZU_8AjRGQaFHMcJjT6t3Wla9Qc)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 68 bytes
```
->n{[*1..n].permutation.map{|c|c.each_slice(2).map(&:sort).sort}|[]}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOlrLUE8vL1avILUot7QksSQzP08vN7Gguia5JlkvNTE5I744JzM5VcNIEySsoWZVnF9UoqkHImtromNr/xcopEWbxHKBKLPY/wA "Ruby ‚Äì Try It Online")
[Answer]
# [SageMath](https://www.sagemath.org/), 35 bytes
```
lambda n:PerfectMatchings(n).list()
```
[Try it on SageMathCell!](https://sagecell.sagemath.org/?z=eJxLU7BVyEnMTUpJVMizCkgtSktNLvFNLEnOyMxLL9bI09TLySwu0dDk5VIgAHi50vKLFDIVMvMUNAz19Ew0rSB6Cooy80o00tSrjRS0FDJrFXTtFKrTNMAczVp1TQBQKx70&lang=sage&interacts=eJyLjgUAARUAuQ==)
[Answer]
# Rust, 225 bytes
My other attempts where even longer. So much `collect().collect()..`
```
fn f(e:u8)->Vec<Vec<(u8,u8)>>{let g=|t,e|if t+1<e{t+1}else{t+2};if e==0{vec![vec![]]}else{(1..e).flat_map(|q|f(e-2).iter().map(|o|o.iter().map(|m|(g(m.0,q),g(m.1,q))).chain([(0,q)]).collect()).collect::<Vec<_>>()).collect()}}
```
[Answer]
# [Rust](https://www.rust-lang.org), ~~191~~ 186 bytes
```
fn f(e:u8)->Vec<Vec<[u8;2]>>{if e>0{(1..e).flat_map(|q|{let mut k=f(e-2);for r in&mut k{for m in r.iter_mut(){for n in m{*n+=(*n>=q)as u8}}r.push([q,e])}k}).collect()}else{vec![vec![]]}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=1ZTBToNAEIYvnvoUKwczU4G2xJimCJ49efNCSEPqUons0tLFC-yTeOlB38H4JvokHt3dGm1Nq0ZtogeWfz6S3fmGwPVNWc3EXWQ5Dj3PRFbwwOt6PcsmlnNqxY87TyknLMk4IKlbnY6qUqCDqo9OeEZHR_qCqm8rEIZ1TgUZB42waZOlROz3jmitVknzmQ6e9BWmQdCtr-hoNzJLHC8eQ891KbppnoghSybQTBt1kuOhmwlaAroGFk2xUrMGxsDcrj1FW4eeCoju6EK3HIHmsSqLPKcjAfgaBwPT-jAMlyCglJ86_rbBHjCbY_M6u0bNyQE9uykmM1L1fW2o7Tii_I9qwLQRezOyuQb8DWz_jYXddQ5m6KwS5DJY6PhpUZKSZHzP0FqVxiHjpKzbbD9QfbeXTPw2X7AlGSnfbVK6k2p2AUYN5aVc7t5Md2Xem3widZoX_1iHMGJkdOQ6snqtwwaJSEnEf1VCKYTBpwZTm37F4LYSqdN_uN--hvlmhooCfmz0PYOTSZlxkfNdsOrBsVS_9hQ8RL-1hh9s4Ieav2w4ny_uzw)
A golfed version of [mousetail's solution](https://codegolf.stackexchange.com/a/249914/78410).
-5 bytes thanks to alephalpha. Didn't realize that `r.iter_mut()` can save a separate `for r in &mut k`.
List of changes:
* I decided to remove `.collect::<Vec<_>>()` right inside `flat_map` in favor of taking an owned Vec (that is returned from `f(e-2)`) and modifying it.
* Then, since both fields of `(u8,u8)` are being modified using the same formula, I decided to change its type to `[u8;2]` and iterate over it instead.
* Finally, switching to 1-based solution saved a few bytes related to arithmetic.
[Answer]
# [lin](https://github.com/molarmanful/lin), 52 bytes
```
.\n $`.n `t2`comb.n2/ `comb \; `#
`flat dup `uniq `=
```
[Try it here!](https://replit.com/@molarmanful/try-lin) Returns an iterator with 0-indexed results.
For testing purposes (use `-i` flag if running locally):
```
6 ; `_ wrap_
.\n $`.n `t2`comb.n2/ `comb \; `#
`flat dup `uniq `=
```
## Explanation
Assuming even integer input *n* (`.\n`).
* ``$ `.n `t` push range `[0..n)`
* `2`comb` length-2 combinations
* `.n2/ `comb` length-(*n*/2) combinations
* `\; `#` filter...
	+ ``flat dup `uniq `=` check if element flattened is unique
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 20 bytes
```
UQ(SNSN*_CHa/2MPM,a)
```
[Try It Online!](https://dso.surge.sh/#@WyJwaXAiLCIiLCJVUShTTlNOKl9DSGEvMk1QTSxhKSIsIiIsIiIsIi1wIDQiXQ==)
Operating on the range \$[0,n)\$ instead of \$[1,n]\$.
I'm just porting some of the other answers here like the Jelly and Vyxal one, so hopefully it is right.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 112 bytes
Prints space-separated lists of comma-separated 0-indexed values.
```
f=(n,i=0,m,o,g=j=>++j<n?g(j,m&(q=1<<i|1<<j)||f(n,i,m|q,[o]+[i,j]+' ')):f(n,i+1,m,o))=>2**n+~m?i<n&&g(i):print(o)
```
[Try it online!](https://tio.run/##JY3NDoMgEITvfYo9CSu0qZ6Mgj6I8WBMNRAB/@Kltq9uwV5mdrJfZnS7t2u3qGm779l59pJaruSTG@74ILUsGdPCVgPV3ER0lokQ6vCi8Tj6wHJzzLx2DasV1w0jQBDz68OS0IIoyzSOLfuaSgkbRQNVmE@Lsht1ePZuoRYkpAVYEBKy4MxnhPcNoHN2dePrMbqBkjqABFgggDQEC0/4qcv/jf78nD8 "JavaScript (V8) ‚Äì Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~12~~ 11 bytes
```
{mSSMcd2.PS
```
[Try it online!](https://tio.run/##K6gsyfj/vzo3ONg3OcVILyD4/38TAA "Pyth ‚Äì Try It Online")
```
{mSSMcd2.PS
          S  Range from 1 to the input
        .P   Permutations
 m           For each permutation:
     cd2      - Chop into chunks of size 2
   SM         - Sort each chunk
  S           - Sort the list of chunks
{            Deduplicate
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 10 bytes
```
≈í!s2·π¢‚Ç¨·π¢∆ä‚Ç¨Q
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700KzUnp3LBgqWlJWm6FluOTlIsNnq4c9GjpjVA8lgXkA5cUpyUXLz6cPvRSQ93zgAKRELULo42i4VqAwA)
Now that it's been beaten, I'll post my own answer (also [previously shared in chat](https://chat.stackexchange.com/transcript/240?m=61551172#61551172)).
Explanation:
```
≈í!            permutations of (implicit range from 1 to) n
       ∆ä‚Ç¨     for each permutation:
  s2            split into chunks of 2
    ·π¢‚Ç¨          sort each pair
      ·π¢         sort the list of pairs
         Q    remove duplicates     
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 59 bytes
```
ÔºÆŒ∏‚äûœÖ‚ü¶‚üßÔº¶‚äóŒ∏¬´‚âî‚ü¶‚üßŒ∑Ôº¶œÖ¬´Ôº¶‚åïÔº°Ôº•Œ∫Ôº¨Œª¬π‚äûŒ∑Ôº•Œ∫‚éá‚ÅªŒªŒΩŒº‚Å∫Œº‚ü¶Œπ‚üß¬ø‚ÄπÔº¨Œ∫Œ∏‚äûŒ∑‚äûÔºØŒ∫‚ü¶Œπ‚üß¬ª‚âîŒ∑œÖ¬ªÔº©Œ∑
```
[Try it online!](https://tio.run/##TY49C8IwEIbn9lfceIE4iKOTKIJgtYNb6RBtNME0rfkQRPzt8axFvOU@3ufeu5MS7tQJk9LG9jHsYnuUDm9snpfRK4wcqpqac@cAV108GtmQyuCZZwvv9cViVXNQhGQDEwfpW6@1bRbGYCF6vHLYSnsJCg1jHKZkMRxQHEb5IJ0V7oGFttGj4WCJazmUhlrKla4ZBR3K9BlwK73H0fJK5O3P8ZP3vXQidO5jPazS4uv3NEGRJq@8dNoGXAofUBGT0ixN7uYN "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Takes `‚Åø‚ÅÑ2` as input. Explanation:
```
ÔºÆŒ∏
```
Input `‚Åø‚ÅÑ2`.
```
‚äûœÖ‚ü¶‚üß
```
Start with a pairing of no numbers.
```
Ôº¶‚äóŒ∏¬´
```
Loop from `0` to `n`.
```
‚âî‚ü¶‚üßŒ∑
```
Start collecting pairings
```
Ôº¶œÖ¬´
```
Loop over the existing pairings.
```
Ôº¶‚åïÔº°Ôº•Œ∫Ôº¨Œª¬π
```
Loop over the unpaired numbers in this pairing.
```
‚äûŒ∑Ôº•Œ∫‚éá‚ÅªŒªŒΩŒº‚Å∫Œº‚ü¶Œπ‚üß
```
Pair the current number with that unpaired number.
```
¬ø‚ÄπÔº¨Œ∫Œ∏‚äûŒ∑‚äûÔºØŒ∫‚ü¶Œπ‚üß
```
If there is room then also add the number as an unpaired number.
```
¬ª‚âîŒ∑œÖ
```
Save the resulting pairings.
```
¬ªÔº©Œ∑
```
Output the final pairings.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 114 bytes
```
f=(n,[i,...a]=[...Array(n)].map((_,i)=>i+1))=>i?a.flatMap(j=>f(n,a.filter(k=>k-i&&k-j)).map(r=>[[i,j],...r])):[[]]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fZjPctowEMbvHPsEOnTAnhiTgG15kjGZHnpoZ_pnJkfiKR5iiBNiGON02iF-kl5yaB-qfZpKgLC0q8UXW9Jv91v0Icnw63e5ustfX_881_N-_LeaJ07pTQrP9_0sTSbi9q6qsp9O6ab-U7Z2nG9e4Sbj4uzClbfrzJ8vs_qTGHlIxnMRKzqKZZ1XzmMyfuwX3e5j_8F1d7FVMp6I1A-pzF6lrns5maTpXvnfm_Kq05l2zll_zLbbpukM90_bC48NG9EO9LbHtiOPBY18kD0j-TDUe4JDz0jGRrZYcQ89Fh0j1Ego74FtJDqMhBZdmE2N4GxqBGdra4bZAj3byDYSHatXI6Gezagg1Kse2UZUtnY-I5AtRCMBqiACVQfSi_iUF-LOPRajmVcEl_foFBEfCH7CV0pFEbSKImiV1lVKJdJVwlNEfPzUkOC6irVSrn9aqwoHKvj7HgMVXEcMVGiCIxW8duCMQQL7AgnsC16HlArtPiRoFdp9SGD3IYHdVwTtPiSw-5DA7iuCdh8S2H1IYPfxXgdnDBLYF0hgX_C-SakoglZRBK3S7sGUSqSrhKcI7L4iuK5irZTrn9aqwoEK9iUGKriOGKjQBHYfn01wxiCBfYEE9gWfc5RKoFdqVVEErdKemZSK4X5wimjXDSS4rmKt1HDfqsKBCvYlBiq4jhio0ARHKvhdAs4YJPB6gQReL_i9hFIx3LeqGO5bVdp3HEolBPNBE9h9RRjuWys1dgerCnQfv6_FQAXXEQMVmuBIhdvcN77JkMD7GCTwPqYIw32rirE7WFWg-1jFcN-qYpxAwSkCr0pFGDuMtVLjBLKqwB0G-wLdx3VA92kC_8aJCfc5SeDzBRL4fFEEdB_ngO7TBK0C3cc5oPs0gXdLRUD3cQ7oPk3gVakIuMPgOuAOQxOa-01n6tdV8eS4_ma9LGqnd1v2XH--qt5ns3unzjc1S8Tvwg5js1UpGhOPFeX6ufZY_mOdz-qbukpZwiToP2W1iBk4_pkrf0zK-8C9OobuAwT88ebLZ3-dVZvcOSbxq3y9zGa5M7jdDhYe601EGce-ZteV9lwtXZVvnpcy3dzZ5fpQ1s6uNB1aZ5uNQPYy_jIvF_U9S5LkEK16ul0RIa8DmH_Pq58ibVEV5UJOwAGfF-XdblK-HocOgfI68LqMxiItPaQVlGp6lCFp6slLjeiiQ1NDXs707VZmb6Y7QrRUoOh5eWHk8OQibTyteZ42U1dL7qpGO-urZe4vVwtnN_fXrHf7POTnYY9d7h-DWe_4Her1x6Kxn1wR37hX-7-d1B9f_wE)
]