Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^5: short sorts

by Arunbear (Prior)
on Apr 07, 2012 at 15:37 UTC ( #963922=note: print w/replies, xml ) Need Help??

in reply to Re^4: short sorts
in thread short sorts

I've been trying to learn Haskell for greater good. It's a functional language, which (among other things) means functions are first class citizens: you can pass them as arguments to other functions, return them from functions, and easily combine them with other functions.

e.g. whereas in Perl you can create a new string with
$foo = $bar . $ram . $ewe;
in Haskell you can create a new function with
f = g . h . i
(assuming all the argument types match up).

That's what the Compose function I wrote does. I thought of doing that after noticing how similar your various sort functions were, and how they could be built by composing/layering basic operations on top of one another.

I'm not suggesting you write your code like that, I wrote it mainly out of curiosity to see what such a functional style would look like in Perl.

Replies are listed 'Best First'.
Re^6: short sorts
by topher (Scribe) on Apr 25, 2012 at 22:50 UTC
    If you're really interested in functional style programming in Perl, you should check out Higher Order Perl, by Mark Jason Dominus. The whole book is about applying functional programming techniques and style to Perl. It's a pretty amazing book. It's also available free online. Hard to beat that.
      I've got a copy already. It is very educational, but doesn't have much to say about composing functions (as far as I can tell).
Re^6: short sorts
by Lady_Aleena (Curate) on Apr 10, 2012 at 02:02 UTC

    I am very happy that I gave you something with which to experiment. If you think of anything else you want this to do, please let me see! :)

    Have a cookie and a very nice day!
    Lady Aleena

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963922]
[atcroft]: Discipulus: I looked back at your note about my Padre question from a while back, and it made me look again... as a result, I found what I was missing and was able to make the change. Thank you!
[LanX]: maybe better /msg discipulus ?

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-02-24 20:35 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (311 votes). Check out past polls.