Add function to compute length of a path with a given distance function and fixed typo