Molarity

Run this example

# 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)