Another remaining issue is that, as I said, all the example here and in the wiki basically assume step > 0. If increment d is dynamic and can be either positive or negative, you have to write something like