What does this function do?

Discussion in 'Rebol' started by MaxV, Aug 27, 2012.

  1. MaxV

    MaxV Member

    I have a lot of problem to understand what this function does:
    iter: func [idx start end step  /local stack][
      stack: head []
      while [tail? stack: at head stack idx] [insert tail stack none]
      if stack/1 = none [stack/1: end ]
      stack/1: stack/1 + step
      if stack/1 > end [stack/1: start]
    It's used by http://www.rebol.org/view-script.r?script=easy-drawer.r to rotate the images.
  2. Graham

    Graham Developer Staff Member

    It appears to setup a block that persists the data between calls ( because it uses stack: head [] without a local copy ).
    You then can summate a series between two values using a step value, and return the sum which is at the head of the stack variable.

Share This Page