Hacker Newsnew | comments | show | ask | jobs | submit login
Underscore Perl (github.com)
3 points by zeeone 1452 days ago | 3 comments



This is... not useful. Perl doesn't have a (weak) functional-programming gap that needs fixing that badly in the first place. The big clue should have been when map had to be defined in terms of... map. Perl's map can be used directly to do the vast bulk of things in that file:

    # reducing; folding is obvious from here
    my $accum = 0;
    map { $accum += $_ } @nums;

    # filter
    map { $_ ? ($_) : () } @list;
    # also grep, of course, but if you want to filter and
    # do other things it's useful

    # flattening
    map { @$_ } @arrayrefs;
For the rest, just look at the source code and observe, for instance, the pointless wrapping of List::Utils::uniq for unique. Far more idiomatic or established ways of doing all (or almost all, with the remainder being easily fixed up from CPAN) these things exist in the core shipped modules. The actual use of this library is almost certain to be both klunkier and less idiomatic and readable than what Perl ships with out of the box.

Underscore is not the sine qua non of weak functional programming.

-----


You're being too harsh. I think Underscore.pm provides an unified interface to a lot of missing array functions. Big deal that it overlaps some existing CPAN/Core Perl functionality. I would easily replace the List::* modules with this.

-----


It's good that he thought of using pre-existing works instead of reimplementing them. Don't knock that.

-----




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: