I want to use the output of HoldComplete as the input of CodeFormat, as shown below:
In[106]:= count=0;(matrices=NestWhile[(Print[count++];
Union[#~Join~Flatten[Outer[Dot,{gMatrix,hMatrix,kMatrix},#,1],1]])&,{IdentityMatrix[7]},Length[#2]!=Length[#1]&,2,99])//Length//Timing//HoldComplete
Out[106]= HoldComplete[
Timing[
Length[matrices =
NestWhile[(Print[count++];
Union[Join[#1,
Flatten[Outer[Dot, {gMatrix, hMatrix, kMatrix}, #1, 1],
1]]]) &, {IdentityMatrix[7]}, Length[#2] != Length[#1] &,
2, 99]]]]
In[104]:= CodeFormat["
Timing[Length[
matrices =
NestWhile[(Print[count++];
Union[Join[#1,
Flatten[Outer[Dot, {gMatrix, hMatrix, kMatrix}, #1, 1],
1]]]) &, {IdentityMatrix[7]}, Length[#2] != Length[#1] &, 2,
99]]]
"]
Out[104]= "Timing[
Length[
matrices =
NestWhile[
(
Print[count++];
Union[Join[#1, Flatten[Outer[Dot, {gMatrix, \
hMatrix,
kMatrix}, #1, 1], 1]]]
)&
,
{IdentityMatrix[7]}
,
Length[#2] != Length[#1]&
,
2
,
99
]
]
]"
How to integrate the above process to obtain the final expression in the following form instead of the formatted result of the string?
Timing[
Length[
matrices =
NestWhile[
(
Print[count++];
Union[Join[#1, Flatten[Outer[Dot, {gMatrix, hMatrix,
kMatrix}, #1, 1], 1]]]
)&
,
{IdentityMatrix[7]}
,
Length[#2] != Length[#1]&
,
2
,
99
]
]
]
Best regards,
Zhao