I have a function I wrap a lot of my numbers with to factor them and display them out a certain way. Usually I do this at the last step of a calculation, but sometimes it would be nice if I could designate that a number should be displayed one way, but handled another way for computation.
For example, suppose I wanted prime numbers in some list to be printed out bold. I might do that with:
nums = If[PrimeQ@#, Style[#,Bold], #]& /@ nums
The problem is that if I then want to, say, take all the elements in that list that are under 100, any code that hits Style
instead of a number will freak out.
Is there something like a wrapper that designates an expression to be handled as some value for subsequent evaluation, but print out a certain way when it comes to display preparation? I know you could achieve this by messing with $PrePrint
, but it seems like there might be a better way.
nums = Interpretation[If[PrimeQ@#, Style[#, Red], #], #] & /@ Range[15]
and then2*nums
. $\endgroup$