1234567891011121314 |
- # This script calculates and prints the molarity of a salt
- # water solution, given a fixed mass of salt (NaCl) and a
- # volume of water.
- let molar_mass_NaCl = 58.44 g / mol
- fn molarity(mass: Mass, volume: Volume) -> Molarity =
- (mass / molar_mass_NaCl) / volume
- let salt_mass = 9 g
- let water_volume = 1 L
- print(molarity(salt_mass, water_volume) -> mmol / l)
- assert_eq(molarity(salt_mass, water_volume), 154 mmol/l, 0.1 mmol/l)
|