Version 2 of string reverse

Updated 2006-11-10 12:32:17 by suchenwi

string reverse string

Returns a string containing the characters of its input argument, string, in reverse order.


Implemented in the Changes in Tcl/Tk 8.5, as part of TIP #272[L1 ].

Workaround substitute for 8.4:

 proc string'reverse str {
    set res {}
    set i [string length $str]
    while {$i > 0} {append res [string index $str [incr i -1]]}
    set res
 } ;# RS
 % string'reverse "hello, world"
 dlrow ,olleh

[Tcl syntax help|Category Command|Category String Processing]