Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Is there a more functional regex syntax?

by BrowserUk (Pope)
on Sep 18, 2012 at 18:09 UTC ( #994326=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Is there a more functional regex syntax?
in thread Is there a more functional regex syntax?

I have always shied away from List::Util ...

Personally, I think List::Util should be incorporated into the core; so often do I use it in my programs.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re^3: Is there a more functional regex syntax?
Re^4: Is there a more functional regex syntax?
by tobyink (Abbot) on Sep 18, 2012 at 19:18 UTC

    Some parts of List::Util are a little ill-conceived. For example, the existence of separate min and minstr functions (and max/maxstr). Perl gets by with a single sort function that can take an optional block. Obviously there is a limit to what can be done with prototypes, but if List::Util were to be adopted into the Perl language itself, I'd hope that would be addressed.

    But certainly, the functions in List::Util would be a lot more useful in core than getgrent, setnetent and getgrgid.

    I'd also add uniq from List::MoreUtils and about half of Scalar::Util.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Some parts of List::Util are a little ill-conceived. For example, the existence of separate min and minstr functions (and max/maxstr).

      Two points:

      1. All of List::Utils function except shuffle, can be reproduce using reduce alone.

        Adding uniq() would be nice if it ran more quickly than a pure perl implementation: sub uniq{ my %h; undef @h{ @_ }; keys %h }

      2. The need for min/minstr is forced by being non-core.

        min amd minstr run more quickly than their equivalents using reduce, because they avoid the need to callback to Perl for every item.

        Sort gets away with using a callback by recognising the simple patterns of callback block {$a<=>$b} & {$a cmp $b} and bypassing them in favour of dedicate opcodes for those simple cases.

        Effectively, sort{$a <=> $b } is the subroutine name. sortn would be shorter, easier to type and remember. Ditto for sorts

        List::Util doesn't have that option because it is outside the core.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-07-13 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (245 votes), past polls