Skip to content

Instantly share code, notes, and snippets.

@schmir
Created November 19, 2014 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmir/22feb44ffd17915145c7 to your computer and use it in GitHub Desktop.
Save schmir/22feb44ffd17915145c7 to your computer and use it in GitHub Desktop.
(defn code-points-from-string
[^String s]
(iterator-seq (.iterator (.codePoints s))))
(defn string-from-code-points
[s]
(let [ia (int-array s)]
(String. ia 0 (count s))))
(defn decode-with-fn
[f ^String s]
(->> s
code-points-from-string
(map f)
string-from-code-points))
(defn decoder1
[c]
(if (> c 1000)
(- c 127247)
c))
(decode-with-fn dec (decode-with-fn inc "ralf"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment