Skip to content

Instantly share code, notes, and snippets.

@iammateus
Created January 4, 2022 23:43
Show Gist options
  • Save iammateus/4c74b93d5fa4507ebe654a914c9ef044 to your computer and use it in GitHub Desktop.
Save iammateus/4c74b93d5fa4507ebe654a914c9ef044 to your computer and use it in GitHub Desktop.
Invert string in Clojure
(ns tutorial.string-utils
(:gen-class))
(defn invert_str
"Invert a string"
[value]
(def end (- (count value) 1))
(loop [index end result ""]
(if (not= -1 index)
(recur (- index 1) (str result (.charAt value index))) (println result))))
(defn -main
"Invert a string"
[value]
(invert_str value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment