Decimal commas instead of points

Fyi, using Mason’s ReplMaker.jl we can get an interesting REPL with minimal effort, which accepts as input the decimal comma as decimal separator and the point as thousands separator. (Not exactly the OP requirement, but at least it can help to check the grocery cost-of-living.)

using ReplMaker

comma2point(str) = Meta.parse(replace(str, r"[-?0-9]{1,3}(.[0-9]{3})*(\,[0-9]+)?" => s -> replace(s, "."=>"", ","=>".")))


initrepl(comma2point,
    prompt_text="decimal-commas> ",
    prompt_color=:blue,
    start_key=',',
    mode_name="decimal-comma"
)


# Type comma `,` in the REPL to start (may need backspace first):
decimal-commas> 11.123,337 + 456,5 + 5.400              # 16979.837
decimal-commas> x = [11.123,337,  456,5,  5.400]        # 3-element Vector{Float64}
decimal-commas> using Statistics
decimal-commas> (sum(x), mean(x), std(x))               # (16979.837, 5659.95, 5338.17)
2 Likes