Skip to content

Instantly share code, notes, and snippets.

@jooyunghan
Created March 1, 2016 08:36
Show Gist options
  • Save jooyunghan/88a129b15b48f914b31f to your computer and use it in GitHub Desktop.
Save jooyunghan/88a129b15b48f914b31f to your computer and use it in GitHub Desktop.
Look-and-say sequence in Clojure using Lazy sequence
(defn nn [s] (->> s (partition-by identity) (mapcat (juxt count first))))
(defn ant [] (iterate nn [1]))
(-> (ant) (nth 1000000) (nth 1000000))
@jooyunghan
Copy link
Author

jooyunghan commented Oct 18, 2016

(iterate #(mapcat (juxt count first) (partition-by identity %)) [1])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment