Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by sgt (Deacon)
on Dec 15, 2006 at 00:24 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-18 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found