[back]

Reversing Strings

Implement the function

val rev : string -> string

so that rev s is the string with the same characters as s but in reverse order. Do this without converting the string into a list of characters. See the functions in Stdlib320.String to get a sense of the possible approaches.

Examples

let _ = assert (rev "testing" = "gnitset")
let _ = assert (rev "12345" = "54321")
let _ = assert (rev "noon" = "noon")