Ok. I'm obviously not understanding something about pattern matching.
I have a list called t
like the following:
t = {{3.2,5.9,Indeterminate},{4.5,-3 - 100 (1 - 2/(Underflow[] + 1)) + 200 (1 - Underflow[]),7.9},{1.2,9.1,2.3}}
Where I would like to use ReplaceAll[]
to convert all non-real values to 0.0, like so:
{{3.2,5.9,0.0},{4.5,0.0,7.9},{1.2,9.1,2.3}}
How could I do this with ReplaceAll[] and pattern matching?
I have tried:
t /. r_ /; Head[r] != List | Real -> 0.0
But that does nothing to the list. I am trying to wrap my head around pattern matching, but I'm not quite there yet, and any help would be greatly appreciated.
Thanks!
P.S.- I would really like to understand this in context of pattern matching, but other more efficient ways of doing this are also appreciated!