In the example code which follows I define a two variable conditional function h[_i, _v], one variable denotes the integer index i, and the other is an N-dimensional vector v (I denote dimension 'N' by 'Num'). I am interested in how to do a folding list type evaluation (or any other efficient method) of this two variable function h[_i,_v], where we carry over the evaluated vector value v to the next index i.e. For Num = 3 I am looking for $$h[3,h[2,h[1,v]]].$$ The code which defines this function h is as follows:
Num = 3; p;
M0 = {{Sqrt[1 - p], 0}, {0, Sqrt[1 - p]}}; M1 = {{Sqrt[p],
0}, {0, -Sqrt[p]}}; Id = {{1, 0}, {0, 1}};
A1 = Table[Id, {i, Num - 1}]; PrependTo[A1, M0]; Pe = Permutations[A1];
MM0 = Table[KroneckerProduct @@ Pe[[i]], {i, Length[A1]}];
A2 = Table[Id, {i, Num - 1}]; PrependTo[A2, M1];
Pe = Permutations[A2];
MM1 = Table[KroneckerProduct @@ Pe[[i]], {i, Length[A2]}];
e1 = RandomVariate[UniformDistribution[{0, 1}], Num]
e2 = RandomVariate[UniformDistribution[{0, 1}], Num]
f[i_, v_] := MM1[[i]] . v/Norm[MM1[[i]] . v]
g[i_, v_] := MM0[[i]] . v/Norm[MM0[[i]] . v]
h[i_, v_] := If[e1[[i]] < e2[[i]], f[i, v], g[i, v]]
The available documentation seems to specifically address the single variable FoldList case. Thanks for any assistance.