Given a list of functions list and a vector of arguments {t, a}:
list = {
h = f[t, x, y, z, a],
x = f[a, b],
p = f[r, n, t, g],
r = f[b, h, z],
n = f[z, h, r, t],
b = f[t],
z = f[x, y, a],
y = f[x, a, b],
}
I like to sort list by exploiting the Recursive structure of the functions in list. The expected outcome should be of the form:
List1 = {
b = f[t],
x = f[a, b],
y = f[x, a, b],
z = f[x, y, a],
h = f[t, x, y, z, a],
r = f[b, h, z],
n = f[z, h, r, t]
}
Note that p = f[r, n, t, g] is not included in the final output as g is not known.
Defining a function taking on two inputs: a given list of arguments v ={t, a} and an unordered l = list might be an option to automate the operation of interest. Such as
orderedF[v_, l_]:=...
If any of the function(s) in list does not have a sufficient number of predetermined arguments, then that function should be excluded from the final list to be generated. Namely, orderedF[] should only give a list of functions with arguments which are all predetermined. Those functions with an insufficient number of predetermined arguments should be identified as a separate list of functions.
EDIT More detailed sorting rule:
- That
tis already known fully identifiesb=f[t]; - That
a, bare known fully identifiesx = f[a, b]; - That
a, b, xare known fully identifiesy = f[x, a, b]and so on; - That
gis not known at all makesp = f[r, n, t, g]as an undetermined function, which should be kept out of the final outcome list.





v = {t, a}. $\endgroup$pshouldn't be in the list, but it is in your expected outcome. $\endgroup$v = {t, a}denotes a given (predetermined) vector, which I like to use it in theorderedF[v_, l_]:=.... I just wanted to show that this function should take a vector and a list as inputs. $\endgroup$