7
$\begingroup$

I have a simple question coincerning the Mathematica function Tuple.

Currently, I apply the following code

x = {1, 2, 3};
Tuples[x, 2]

Obviously I get:

enter image description here

How can I delete all self-loops from this list, i.e., delete {1, 1}, {2, 2}, {3, 3}? Is there a built-in function?

$\endgroup$
10
$\begingroup$

I think you want Permutations:

Permutations[{1, 2, 3}, {2}]

{{1, 2}, {1, 3}, {2, 1}, {2, 3}, {3, 1}, {3, 2}}

$\endgroup$
  • $\begingroup$ perfect. Thanks a lot $\endgroup$ – Julian Aug 27 '14 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.