Created
January 4, 2022 23:43
-
-
Save iammateus/4c74b93d5fa4507ebe654a914c9ef044 to your computer and use it in GitHub Desktop.
Invert string in Clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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