• outdated_belated
    link
    fedilink
    arrow-up
    13
    ·
    2 years ago

    Nah, look at the implementation above:

    n <= 4

    Means it’s inclusive.

    You’re probably referring to some other implementation that doesn’t involve such fine control, like Python where range(4) means [0 1 2 3]

    • radix@lemm.ee
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Oh yeah, I meant generally. Isn’t it most common if not best practice to say for (i = 0; i < whatever; i++)?

      • outdated_belated
        link
        fedilink
        arrow-up
        2
        ·
        2 years ago

        Fair. I guess to accommodate zero-indexing so that it still happens whatever times, not whatever + 1 times.