Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by runrig (Abbot)
on Sep 09, 2008 at 16:03 UTC ( [id://710128]=note: print w/replies, xml ) Need Help??


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

Here's another awk solution (different strategy, and slightly shorter when compacted - Update: this reverses every line, and if your's did the same, i.e, without the END block, it would still be shorter than this...oh well):
#!/bin/awk -f { for (i=1; i<=NF/2; i++) { t=$i $i = $(NF-i+1) $(NF-i+1)=t } print }
  • Comment on Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-16 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found