module figure_5_8
public  ::  distance
contains
! Figure 5.8
   function distance(p, q) result (d)
      real, intent(in), dimension(:) :: p, q
      real :: d
      d = sqrt( (p(1)-q(1))**2 + (p(2)-q(2))**2 +    &
                       (p(3)-q(3))**2 )
      ! The intrinsic function sqrt is defined in Section 8.4.
   end function distance
end module figure_5_8
