Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created March 6, 2016 01:48
Show Gist options
  • Select an option

  • Save Vaguery/9a0803fef8c17a2c15c7 to your computer and use it in GitHub Desktop.

Select an option

Save Vaguery/9a0803fef8c17a2c15c7 to your computer and use it in GitHub Desktop.
Some rewriting experiments
(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