1. Fool newbie question
- Posted by Tony Bucholtz <tony_bucholtz at HOTMAIL.COM> Dec 14, 2000
- 318 views
G'day all Using a "for" loop to look at each element of a sequence, e.g. for i = 1 to length(seq) is the results of length(seq) re-evaluated for each pass thru the loop? Two reasons for asking: 1. if so, then x = length(seq) for i = 1 to x would be more "efficient"?? 2. shortening / truncating the sequence in one of the loops will stop the loop?? Or just crash and burn when trying to reference the now nonexistent part of the original sequence?? TIA Regards Tony
2. Re: Fool newbie question
- Posted by David Cuny <dcuny at LANSET.COM> Dec 14, 2000
- 308 views
Tony Bucholtz wrote: > Using a "for" loop to look at each > element of a sequence, e.g. > for i = 1 to length(seq) > is the results of length(seq) re-evaluated > for each pass thru the loop? No; here's a demonstration: sequence s s = "1" for i = 1 to length( s ) do s &= "2" end for puts( 1, s ) If it was re-evaluated each time, you'de be in an endless loop. -- David Cuny
3. Re: Fool newbie question
- Posted by Tony Bucholtz <tony_bucholtz at HOTMAIL.COM> Dec 14, 2000
- 339 views
G'day all David, thanks for that - I hadn't thought of the reverse case (a growing sequence) Regards Tony