Question: Composition of functions

I have entered three functions into Maple and I would like to create a set of all possible two-function and three-function compositions involving the three functions. For instance, for my three functions f(x), g(x) and h(x), the set would contain f(g(x)), g(f(x)), f(g(h(x))), f(f(f(x))), etc. 

I'm also looking for a method that will be generalisable to larger numbers of initial functions than just three.

Please Wait...