# Create a list of all functions given a set of arguments

I'm trying to examine some patterns on the permutation of elements in finite element functions. I'd like to create a list of all functions (256 of them) on 4 elements.

For example

{{(a, b), (b, c), (c, c), (d, a)}, {(a, c), (b, d), (c, c), (d, a)}, ... }


In all the methods I have tried I keep getting non-functional elements, i.e. things like

{{(a, b), (a, c), (c, d), (d, a)}, ... }


Any suggestions as for an easy way to do this?

• You might want to look here – Sektor Mar 25 '15 at 15:54
• What method have you tried such that you're getting 'non-functional' elements? – 2012rcampion Mar 25 '15 at 16:41
• Your "code" is not Mathematica-compatible. Would you mind fixing the round brackets? – Jinxed Mar 25 '15 at 16:41
• Also, let me check that I understand you correctly: you're trying to generate all mappings from the set {a, b, c, d} onto itself? – 2012rcampion Mar 25 '15 at 16:42
• @2012rcampion yes, exactly: your answer below was exactly what I was looking for. – Bradford Mar 26 '15 at 1:45

set = {a, b, c, d};

If you want all permutations (one-to-one mappings from set onto set) replace Tuples with Permutations[set].