Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Re: removing list of elements from a list

Expand Messages
  • Paul Archer
    ... I see what I was missing now (checking the scalar value of the inner grep). Thanks! ... Well, my lists are small, but the point s taken. ... What else is
    Message 1 of 7 , Dec 25, 2004
      11:37pm, Jonathan Paton wrote:

      >
      > > I still think there's a map/grep | map/map | grep/grep solution out there.
      >
      > Of course, if you really want a grep/grep solution then try (untested):
      >
      > my @final = grep {
      > my $value = $_;
      >
      > 0 == scalar grep {
      > $_ == $value
      > }, @remove
      > }, @array;
      >
      I see what I was missing now (checking the scalar value of the inner grep).
      Thanks!


      > However, I strongly advise against it. It will be MUCH slower than a
      > hash based solution for larger sizes of @array and @remove. In fact,
      > for a hash solution you are looking at O(ARRAY + REMOVE), whereas
      > for the grep/grep you have O(ARRAY * REMOVE).
      >
      Well, my lists are small, but the point's taken.


      > There are modules on CPAN for sets, if you are doing more than
      > just having fun.
      >
      What else is there in Perl (besides having fun)? 8-)

      Paul
    Your message has been successfully submitted and would be delivered to recipients shortly.