FOREACH Series Reference Variable
Something I've always wanted in foreach: the ability to access the series, not just its values. In otherwords, kind of a blend of forall and foreach.
One way to do this is to allow the foreach word block to include some kind of notation that a word is meant to refer to the series, not a value of the series. For example:
foreach [name count:] user-data [
change count length? name
]
This example shows the power of the method. Here the count variable refers to the series at that index, so the example is modifying the actual series block here. The set-word notation is consistent with that used in the parse dialect for a similar purpose.
You can also use such a word to get you the index position without needing to increment a separate variable within your foreach loop.
15 Comments
|