Other Nim solutions.
proc reverse*(s: string): string =
if s == "":
return s
var aux = s
for i in 0 .. high(s) div 2:
swap(aux[i], aux[high(aux) - i])
aux
Other Clojure solutions.
(ns reverse-string)
(defn reverse-string [s]
(let [reversed-chars (into () s)]
(apply str reversed-chars)))
Other Rust solutions.
pub fn reverse(input: &str) -> String {
input.chars().rev().collect::<String>()
}
Other Roc solutions.
module [reverse]
import unicode.Grapheme
reverse : Str -> Str
reverse = \string ->
when Grapheme.split string is
Ok chars ->
chars |> List.reverse |> Str.joinWith ""
Err _ -> ""