molarity.nbt 433 B

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