My awk is very rusty too. Unfortunately, your version emits a trailing space, which violates the spec. I've remedied that below and done it in the form of a function so that it can be more easily compared with the other languages.
# File : revwords.awk # Run with : awk -f revwords.awk </dev/null END { print reverseWords(" one two three four ") } function reverseWords(s) { if ((i = split(s, words)) == 0) return "" sret = words[i] while (--i > 0) sret = sret " " words[i] return sret }
In reply to Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
by eyepopslikeamosquito
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |