Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by ambrus (Abbot)
on Dec 12, 2006 at 22:03 UTC ( #589433=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    >>> def reverseWords(words):
    ...     return ' '.join(words.split()[::-1])
    ... 
    >>> reverseWords("  one   two three four    ")
    'four three two one'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589433]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-07-25 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (363 votes). Check out past polls.