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

Let's say I want to find a sample space of such experiment: There are three exits from the box: Left (L), right (R) and front (F). Three mice have been put in that box. Find the sample space of an event which mouse has chosen which exit. Function Permutations[] gives all different outputs.


How can I find also outcomes like {F,F,L}, {R,R,R}... ?

share|improve this question
It's only terminology. The OP has to state if he/she wants variations or combinations. (In other words: Is (LLF) the same as (LFL)?) – Stefan Feb 18 '13 at 14:48
@Ajasja When I use your example, I don't get the event {RRR} which the OP demanded. So Permutations does NOT give the asked results. – Stefan Feb 18 '13 at 15:02
@Misery Please try to re-state your question in an easier to understand way, to avoid all these close and reopen votes. I'd suggest giving an example input and the complete output your desire. – Szabolcs Feb 18 '13 at 15:10
Question should be restated as: Given a list of 3 distinct objects, how does one form the list of all possible triples of these objects, repetitions allowed? – murray Feb 18 '13 at 15:17
I disagree that his question is too localize: 4 upvotes and 6 upvotes on accepted answer shows that it is helping new visitors. I suggest removing the closure by lack of evidence supporting localization. – J. C. Leitão Oct 16 '13 at 9:32
up vote 7 down vote accepted
 Tuples[{l, r, f}, 3]
 (* {{l, l, l}, {l, l, r}, {l, l, f}, {l, r, l}, {l, r, r}, {l, r, f}, 
    {l, f, l}, {l, f, r}, {l, f, f}, {r, l, l}, {r, l, r}, {r, l, f}, 
    {r,  r, l}, {r, r, r}, {r, r, f}, {r, f, l}, {r, f, r}, {r, f, f},
    {f, l,  l}, {f, l, r}, {f, l, f}, {f, r, l}, {f, r, r}, {f, r, f}, 
    {f, f,  l}, {f, f, r}, {f, f, f}} *)


share|improve this answer

The only problem is that you have a recursive definition ( you want L to be a list and outcome).

In general using identifiers that start with a capital letter is best avoided. D and C are some examples of this.

This is much safer and works as expected:

list = {"L", "R", "F"}

If you would like to have "permutations with repetition" then Tuples is the right tool for the job (as kguler already noted):

Tuples[list, 3]
share|improve this answer
And E, and I, and N, and O... – Dr. belisarius Feb 18 '13 at 14:38

Your Answer


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.