Created
March 6, 2016 01:48
-
-
Save Vaguery/9a0803fef8c17a2c15c7 to your computer and use it in GitHub Desktop.
Some rewriting experiments
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
| (defn rewrite-step | |
| [n cutoff replacements] | |
| (let [replaced-string | |
| (reduce | |
| (fn [result digit] (str result (str (nth replacements (- (int digit) 48))))) | |
| "" (str n))] | |
| (read-string (subs replaced-string 0 (min cutoff (count replaced-string)))))) | |
| (def temp-table | |
| (take 10 (repeatedly #(rand-int 1000)))) | |
| (fact "this works" | |
| (rewrite-step 1 10 temp-table) => integer? | |
| (take 30 (iterate #(rewrite-step % 10 temp-table) 1)) => 88) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment