let rec shift d = function
  | _::xs when d>0 -> shift (pred d) xs
  | xs -> xs