Menu

#7 for..in..do

open
nobody
None
5
2002-12-16
2002-12-16
jbrown
No

Add support for this:

for x in s do
x = 0
end for

instead of having to resort to this:

for x = 1 to length(s) do
s[x] = 0
end for

Whether x should be a reference to the element s[x] or a copy, however,
remains open to discussion (in my current version of PEU source its
a copy).

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Probably trickier, but this construct could very usefully apply
    to while loops.

     
  • Nobody/Anonymous

    Logged In: NO

    Is the "for..in" construct an optional form of the standard "for
    x =..." loop, or a separate construct? If it's separate, then
    perhaps "foreach..in" may be better, to distinguish it from the
    standard for loop.

    Tony B
    tony_bucholtz@hotmail.com

     
MongoDB Logo MongoDB