Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,24 @@
F currency(units, subunits)
R BigInt(units) * 100 + subunits
F currency_from_str(s)
V (units, subunits) = s.split(.)
R BigInt(units) * 100 + Int(subunits)
F percentage(a, num, denom)
R (a * num * 10 I/ denom + 5) I/ 10
F to_str(c)
R String(c I/ 100).#02.format(c % 100)
V hamburgers = currency(5, 50) * 4'000'000'000'000'000
V milkshakes = currency_from_str(2.86) * 2
V beforeTax = hamburgers + milkshakes
V tax = percentage(beforeTax, 765, 10'000)
V total = beforeTax + tax
V maxlen = max(to_str(beforeTax).len, to_str(tax).len, to_str(total).len)
print(Total price before tax: to_str(beforeTax).rjust(maxlen))
print(Tax: to_str(tax).rjust(maxlen))
print(Total with tax: to_str(total).rjust(maxlen))