Implement a tail-recursive list map.