Skip to content

Commit

Permalink
make im nice
Browse files Browse the repository at this point in the history
  • Loading branch information
fkastner committed Feb 12, 2021
1 parent ab2cac4 commit 07f454d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/NiceNumbers.jl
Expand Up @@ -165,17 +165,20 @@ norm2(v::AbstractArray{NiceNumber,1}) = sqrt(v'v)

## macro stuff
"""
nice(x, mod = @__MODULE__)
nice(x)
If `x` is an expression it replaces all occuring numbers by `NiceNumber`s.
If `x` is a number it turns it into a `NiceNumber`.
If `x` is the symbol `:im` it turns it into `NiceNumber(im)`.
Otherwise it does nothing.
"""
function nice end
nice(x) = x
nice(n::Number) = NiceNumber(n)
nice(s::Symbol) = s===:im ? NiceNumber(im) : s
nice(ex::Expr) = Expr(ex.head, map(nice, ex.args)...)

"""
Expand Down

0 comments on commit 07f454d

Please sign in to comment.