in reply to round-robin on varying sequence

Did you consider using splice for removal? I think it would be much easier.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: round-robin on varying sequence
by dpuu (Chaplain) on Sep 07, 2002 at 02:16 UTC
    Yes, I did. But splice is not well suited to removing a random set of elements from a list. It works, but you end up using splice to remove single elements at a time. The grep approach appears, IMHO, much more elegant (though I do have duplicated code in the greps). Perhaps you could code up a version using splice to demonstrate why you would prefer it -- then we can benchmark it. --Dave

      Agreed, splice was the wrong idea. How do you like this one?

      sub remove_items { $index -= grep { $_ < $index } @_; delete @items[@_]; @items = grep {defined} @items; }

      I dislike the use of broader scoped $index and @items in this.

      After Compline,
      Zaxo

        I think, and I emphasis, I think, that your solution is different to the original.

        Unless my reading of the Q is wrong, and my benchmark below is crap, in the original the passed array is and array of values to be removed.

        In yours, you seem to be expecting an array of indices?


        Well It's better than the Abottoire, but Yorkshire!