I have a bunch of functions, a.process
, b.process
, c.process
..., let's call them a
, b
, c
... that all take a std::string
as parameter and return a std::string
.
Given an initial std::string s
, I want to generate every possible output of combinations of a
, b
, c
... called in any order and given s
as initial input.
So for instance, I want to calculate a(s)
, b(s)
, c(s)
, a(b(s))
, a(c(s))
, b(a(s))
, b(c(s))
, c(a(s))
, c(b(s))
, a(b(c(s)))
, etc.
I think I could do a function to generate every permutation of a list, something like Python's itertools.permutations
but I have two main issues here:
I don't just want every permutation, I want every permutation in every order.
And more important, I have no idea about how to store functions in arrays like one would easily do in Python.
Also I need that each possible output comes with the combinations of functions that generated it so for the example I gave above, I would know that outputs are in the following order: "a"
, "b"
, "c"
, "ab"
, "ac"
, "ba"
, "bc"
, "ca"
, "cb"
, "abc"
, etc.
How could I implement that in C++?