Page 1 of 1
Repeat with...Repeat for...
Posted: Thu May 19, 2016 11:35 pm
by RossG
Is it necessary to have both "repeat with..." and
"repeat for..."?
Since the next word is either "x" or "each" it shouldn't
be too difficult to make them both "for", the usual
word in other languages.
Re: Repeat with...Repeat for...
Posted: Fri May 20, 2016 11:33 am
by dave.kilroy
Yes
They do different things, both of which are useful - check out 'repeat' in the dictionary
Regards
Dave
Re: Repeat with...Repeat for...
Posted: Fri May 20, 2016 1:04 pm
by dunbarx
"Repeat with", though slower than any other type, is utterly essential, since it manages a repeat index internally. All the others either test a condition, contain no index or other constrant at all, or churn through successive chunks of a container.
One might make a case that "repeat while" and "repeat until" are different aspects of the same conceptual process, but each is useful in its own right if for no other reason than either construction might make more sense depending on how one sets up the loop.
Craig Newman
Re: Repeat with...Repeat for...
Posted: Fri May 20, 2016 2:04 pm
by Mikey
Sometimes I miss the Pascal way of handling Repeat and While, but I do like the different flavors we get with LC, especially the way that repeat for is optimized to increase speed.