printfn / fend

Arbitrary-precision unit-aware calculator
https://printfn.github.io/fend
MIT License
668 stars 52 forks source link

Use $ in identifiers #78

Open NickGeek opened 3 years ago

NickGeek commented 3 years ago

I would like to be able to use $ in fend like $200/3 to 2dp to print approx. $66.66.

printfn commented 3 years ago

Partially implemented in ac1655d8549d378b89b69b38a3763a6b66ac83e5:

> $200/3 to 2dp
approx. $66.66
> $3 * 7
$21

You can test it here.

Unfortunately there are still some cases where the parser produces an error, particularly when $ is part of a larger left-hand side expression with same/higher precedence (e.g. multiplication). In these cases you currently need to write e.g. 7$ instead of $7.

> 3 * $7
Error: $3 is not a function
> 3 * 7$
$21
NickGeek commented 3 years ago

Nice! Would it be worth adding other currency symbols too?

printfn commented 3 years ago

Euro (€) already works, and it's usually written after the number so that should be fine. I'll add support for £ now.