-1

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?

Sektor
  • 3,320
  • 7
  • 27
  • 36
bmf
  • 3
  • 2

1 Answers1

1

Try this:

set = {a, b, c, d};
maps = Thread[set -> #] & /@ Tuples[set, {Length[set]}]

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

2012rcampion
  • 7,851
  • 25
  • 44
  • This is great. And indeed, I was not looking for just 1-1 mappings. Thanks so much. Much better than other options using nests of combinations etc. Thanks again. – bmf Mar 26 '15 at 01:46