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$

1 Answer 1

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$
1
  • $\begingroup$ perfect. Thanks a lot $\endgroup$
    – Julian
    Commented Aug 27, 2014 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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