What function returns all possible permutations with repeating list elements?

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.

L={L,R,F}
Permutations[L]


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

• 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)?) Commented Feb 18, 2013 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. Commented Feb 18, 2013 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. Commented Feb 18, 2013 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? Commented Feb 18, 2013 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. Commented Oct 16, 2013 at 9:32

 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}} *)


?

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"}
Permutations[list]


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]

• And E, and I, and N, and O... Commented Feb 18, 2013 at 14:38