December 22, 2013
On Saturday, 21 December 2013 at 21:49:01 UTC, MrSmith wrote:
> On Saturday, 21 December 2013 at 00:47:04 UTC, aldanor wrote:
>> Is there an efficient method to remove elements with multiple (compile-time-unknown) indices from an array? I currently do something like
>>
>> 		if (!index.empty)
>> 			foreach (i; index.sort.reverse)
>> 				a = a.remove(i);
>>
>> ... which looks a bit awkward.
>
> just use foreach_reverse

Wow, I never knew it is a keyword, thank you!
December 22, 2013
On 12/21/2013 05:39 PM, aldanor wrote:

> On Saturday, 21 December 2013 at 21:49:01 UTC, MrSmith wrote:

>> just use foreach_reverse
>
> Wow, I never knew it is a keyword, thank you!

I feel guilty for omitting in knowingly but we've been hearing that it would be deprecated. I don't think it will ever happen. :-/

Besides, I think retro(), its alternative, is not suitable for recursive algorithms because retro() works only with ranges.

I had once tried to do recursive iteration with ranges (probably on a tree) but it had turned out that iteration with opApplyReverse was more natural for recursion. (I may be wrong on my conclusion but that is what I remember now.)

Ali

1 2
Next ›   Last »