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

Perl functional programming system

by bagyi (Acolyte)
on Sep 11, 2015 at 01:22 UTC ( [id://1141627]=perlquestion: print w/replies, xml ) Need Help??

bagyi has asked for the wisdom of the Perl Monks concerning the following question:

Is there any functional system like Moose for OOP? There are some helpful tools in List::Util. Apart from that I don't know where to look for. I'm thinking of things like lazy evaluation, infinite list, list comprehension, fold, pattern matching, currying.

Replies are listed 'Best First'.
Re: Perl functional programming system
by AnomalousMonk (Archbishop) on Sep 11, 2015 at 01:56 UTC
      Yeah, a decade-old book, indeed, but IMHO the best CS/IT book I read in the last decade.
Re: Perl functional programming system
by Athanasius (Archbishop) on Sep 11, 2015 at 15:32 UTC

    Hello bagyi, and welcome to the Monastery!

    I don’t know of any single, integrated functional system, but contains many modules supplying functional programming features. Here are some:

    Lazy evaluation:

    Infinite lists:

    List comprehensions:

    Folds:

    Pattern matching:

    Currying:

    The presence of so many CPAN modules implementing functional programming features in Perl is hardly surprising, given Mark Jason Dominus’s observation in the Preface to Higher-Order Perl:

    Around 1993 I started reading books about Lisp, and I discovered something important: Perl is much more like Lisp than it is like C. If you pick up a good book about Lisp, there will be a section that describes Lisp’s good features. For example, the book Paradigms of Artificial Intelligence Programming, by Peter Norvig, includes a section titled What Makes Lisp Different? that describes seven features of Lisp. Perl shares six of these features; C shares none of them. These are big, important features, features like first-class functions, dynamic access to the symbol table, and automatic storage management.

    (BTW, just out of curiosity: can someone please enumerate these seven features, and identify the one which is missing from Perl? I’ve often wondered.)

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      can someone please enumerate these seven features, and identify the one which is missing from Perl? I’ve often wondered.)

      See here. He's added an 8th: "history" which is something only a Lisp programmer could claim as important. Algol68 has history; try finding anyone using that.

      Of course; Algol's legacy is in all the features that it introduced to the programming language lexicon. Same can be said (or is at least claimed) by Lisp(ers).

      The missing feature is described above as "Uniform Syntax"; which basically means s-lists: the ability of the language to process itself as data and subsequently execute the resultant data as code. In short proper code macros (as opposed to C's text substitutions.)

      The real problem with programming Perl like it was Lisp -- al la HOP -- is that your 2015 Haswell will perform like a 1993 Pentium.


      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". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
      Thanks for very details reply! I'll look into them. Perl6 seems to have many functional programming features built in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 12:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found