Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

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

Help for this page

Select Code to Download


  1. or download this
       reverseWords =: (,' '&,)&:>/@:|.@:;:
       reverseWords '  one   two three four    '
    four three two one
    
  2. or download this
       reverseWord1 =: [:(,' '&,)&:>/@:|.@:-.&a:e.&' ^'<@}.;.1]
       reverseWord1 '  one   two three^four    '
    four three two one
    
  3. or download this
       reverseWord2 =: [:}.@;@|.e.&' ^'<@(' '&,@}.`(0$])@.(2>#));.1]
       reverseWord2 '  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://589445]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-08 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls