Skip to main content
Tweeted twitter.com/#!/StackMma/status/620725512307130368
edited tags
Link
added 12 characters in body
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 43
  • 76

I have a list {x1,...,xN]{x1,...,xN} where NN is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the output I would like is something like (say N=4N = 4):

{{{x1,x2},{x3,x4}},{{x1,x3}{x2,x4}},...}

{{{x1,x2},{x3,x4}},{{x1,x3}{x2,x4}},...}

How can this be achieved?

I have a list {x1,...,xN] where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the output I would like is something like (say N=4):

{{{x1,x2},{x3,x4}},{{x1,x3}{x2,x4}},...}

How can this be achieved?

I have a list {x1,...,xN} where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the output I would like is something like (say N = 4):

{{{x1,x2},{x3,x4}},{{x1,x3}{x2,x4}},...}

How can this be achieved?

Source Link
sdnnds
  • 383
  • 2
  • 7

Find all the possible ways of partitioning a list into a set of pairs of element

I have a list {x1,...,xN] where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the output I would like is something like (say N=4):

{{{x1,x2},{x3,x4}},{{x1,x3}{x2,x4}},...}

How can this be achieved?