Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)

by TimToady (Parson)
on Dec 12, 2006 at 18:04 UTC ( [id://589343]=note: print w/replies, xml ) Need Help??


in reply to Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)

You're going to have to try harder if you want Haskell to outgolf Perl 6 here. The following all work in Pugs and are shorter than your Haskell version.
sub reverseWords ($_) {~reverse .comb} sub reverseWords {~reverse comb @_} my&reverseWords:={~.comb.reverse}
The first two could even be construed as readable.
  • Comment on Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
  • Download Code

Replies are listed 'Best First'.
Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
by apotheon (Deacon) on Dec 13, 2006 at 08:12 UTC

    If we're really concerned about golfing to the fewest strokes, you should check out the UCBLogo solution in my post down a few in the discussion. In UCBLogo, the number of (key)strokes needed is zero.

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-23 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found