As code-golfers, we're not used to releasing (surely). We're gonna need a few tools to help us do that.
Of course, to help marketing a new release, we need a nice and shiny Release Version. Who doesn't get excited when they hear about version 3.0.0?
Your task will be to write a program/routine/... to increment a version number.
You need to increment the version number and reset the "less important" ones (i.e. patch version).
You get two arguments: the current version (ex "1.0.3") as a string, and an index to know which one to update (0 or 1-indexed).
next-version("1.0.3", 0) # 2.0.0 next-version("188.8.131.52.5", 2) # 184.108.40.206.0 next-version("10.0", 0) # 11.0 next-version("3", 0) # 4 next-version("1", 7) # ERROR next-version("01", 0) # ERROR
The version is a string, each part is a number, separated with a dot. There can be no leading, no trailing or no consecutive dots (and nothing outside of numbers/dots). There is no limit to the size of the version string.
The error case (last two examples) is undefined behavior. What happens in case of wrong inputs is of no relevance to this challenge.
As usual, standard loopholes are forbidden. You're allowed to print or return the string.