Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: Grep Pattern

by ikegami (Patriarch)
on Dec 13, 2018 at 18:25 UTC ( [id://1227210]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Grep Pattern
in thread Grep Pattern

I stand by what I said. Even just hardcoding the 4 warranted horror. And you are mistaken about the restrictiveness of my code.

@a[ grep { $pat[ $_ % @$pat ] } 0..$#a ]
or
sub filter_by_pat { my $pat = shift; return @_[ grep { $pat->[ $_ % @$pat ] } 0..$#_ ]; } filter_by_pat [0,1,1,0], ...

Replies are listed 'Best First'.
Re^5: Grep Pattern
by LanX (Saint) on Dec 14, 2018 at 12:29 UTC
    > And you are mistaken about the restrictiveness of my code.

    Not really.

    There are many occasion where you need to handle a pure list in Perl and your array slice requires storing it in an array.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Let me rephrase: You are definitely mistaken about the restrictiveness of my code. The code I provided handles a pure list.

        Let me rephrase: hdb's code is "definitely" easier and he didn't "mess up the implementation"

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-23 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found