Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Rolling your own ideal looper: does Repeat still have a bug? Re:(4)

From: blazs:orac:au at: 1-Sep-2000 1:22

Hello [lmecir--geocities--com] I only wish I had more time to play around with REBOL :(. On 29-Aug-00, [lmecir--geocities--com] wrote:
> The corrected version: > > ideal-looper: func [ > [throw] > 'element [word!] > 'index [word!] > series [series!] > code [block!] > /local f i > ] [ > f: func reduce [[throw] element [any-type!] index] code > i: 1 > while [i <= length? series] [f series/:i i i: i + 1] > ] >
For what it's worth...would creating another local word to hold the length of the series and then checking it against 'i, as to evaluating the length of the series for each iteration of the while loop? Or is it wise to check the length of the series for each and every iteration, because the series itself could change while iterating across the series? i.e. ideal-looper: func [ [throw] 'element [word!] 'index [word!] series [series!] code [block!] /local f i series-length ] [ f: func reduce [[throw] element [any-type!] index] code i: 1 series-length: length? series while [i <= series-length] [ f series/:i i i: i + 1 ] ] Regards Blaz