What is the correct method to replace all types of infinity e.g. ComplexInfinity
that are present in a Flatten
Table
format with text that can be recognised by other languages e.g. NaN
?
I have // If[ToString[#] == "ComplexInfinity", "NaN", #] &
but at present I must apply this separately to every input variable in Table
as,
f[x_] := 1/x;
g[x_] := 1/(x - 4);
Table[{f[x] // If[ToString[#] == "ComplexInfinity", "NaN", #] &,
g[x] // If[ToString[#] == "ComplexInfinity", "NaN", #] &},
{x, {0, 10, 1}}]
- Is there a better way to iterate this through the
Table
? - As a side note, if I change,
"NaN", #] &
to"NaN", N[#, 4]] &
to include number formatting then it breaks my code
list /. x_DirectedInfinity :> "NaN"
? $\endgroup$GetHelp
interface ;) $\endgroup$