Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by sgt (Chaplain)
on Dec 15, 2006 at 00:24 UTC ( #589948=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)

not too sure about ash but you get less chars with:

 print "${new% }"

another way showing off some aspects of modern shells but still a bit longish...

% stephan@labaule (/home/stephan) % % cat rev.sh #!/bin/ksh93 function rev { nameref s=$1; typeset a=( $s ); integer n=${#a[*]} i; s=; n=n-1 for i in {$n..0}; do s+="${a[i]} "; done; s=${s%?} } s=" one two three four " rev s print "[$s]" % stephan@labaule (/home/stephan) % % ksh93 rev.sh [four three two one]
enjoy ;) --steph


Comment on Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-07-08 04:20 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 (94 votes), past polls