NapkinCalc

Start Here — A Complete Tour

Units are first-class

continues from lesson 1 — values defined earlier in the course stay live here

Numbers can carry units, and NapkinCalc tracks them through every calculation — multiplying, dividing, and converting automatically. A unit mismatch (adding metres to seconds) becomes a visible error, which is exactly how you want a calculator to catch a slip.

distance:=5kmdistance := 5 km = 5 km a length
speed:=60km/hourspeed := 60 km/hour = 60 km / hour a rate
traveltime=distancespeedtravel_{time} = \frac{distance}{speed} = 0.083333 hour km ÷ (km/hour) cancels to a time, automatically
travelmin:=traveltimeinminutetravel_{min} := travel_{time} in minute = 5 minute convert with the in keyword
✓ pass abs(travelmin5minute)<0.000001minute\mathrm{abs}\left(travel_{min} - 5\,\mathrm{minute}\right) < 0.000001\,\mathrm{minute} five minutes — the units worked out

Try writing distance + speed: NapkinCalc refuses, because a length and a rate are not the same kind of thing. That refusal is a feature.