Dynamical systems for metric spaces