Is it possible to get the result of a computation in the form
2pi//5
2√2//3
just like there is for Rationals?
Is it possible to get the result of a computation in the form
2pi//5
2√2//3
just like there is for Rationals?
no, you can probably try to delay the calculation yourself
Depending on what are you aiming for, you can take a look at Symbolics
:
julia> using Symbolics
julia> @variables pi sq2
2-element Vector{Num}:
pi
sq2
julia> formula = 2 * pi // ( 3 * sq2 )
(2pi) / (3sq2)
julia> substitute(formula, Dict(pi => π, sq2 => √2))
1.4809609793861218
There is this package which seems to be heavy on the type piracy but if it’s for private use that’s probably fine.
(There’s a pun on the word “privateer” in here somewhere)