Convert Currency in Larzscript
Convert an amount between currencies with a settable rate table - fully offline, no API call, no hidden currency-tagging assumptions.
fx.set_rate() records a rate (and its inverse automatically), fx.convert() scales a Money amount by it - the package is explicit that Larzscript's Money type isn't currency-tagged, so the caller is responsible for tracking which currency a value is actually in.
larzscript pkg install fx
Code
import "fx" as fx
fx.set_rate("USD", "NGN", 1550.0)
print(fx.convert($10.00, "USD", "NGN"))
print(round(fx.rate("NGN", "USD"), 6))Output
$15500.00 0.000645
Related
larzfxCurrency conversion with a settable rate table, fully offline→Split a Bill Fairly in LarzscriptDivide a bill among people so it reconciles exactly to the cent - no language other than Larzscript treats this as a stack primitive rather than app-level logic.→Hold Funds in Escrow in LarzscriptHold a payer's funds, then release them to a payee or refund them back - using the language's own wallet and pay keywords, not a bolted-on library.→Rate-Limit API Requests in LarzscriptToken-bucket rate limiting in about 20 lines - cap a caller to N requests with a steady refill rate instead of a blunt fixed window.→