Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 10 down vote accepted

I think you want Permutations:

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

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

share|improve this answer
    
perfect. Thanks a lot – Julian Aug 27 '14 at 7:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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