in reply to Re^3: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
It is sometimes hard to not use ::-1 once learnt, but you can use reversed which makes it clearer:
- Paddy
>>> def reverseWords(word): ... return " ".join( reversed(word.split()) ) ... >>> reverseWords(" one two three four ") 'four three two one'
- Paddy
|
---|
In Section
Meditations