Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn walk-chain
[prefix chain results]
(let [suffixes (get chain prefix)]
(if (empty? suffixes)
results
(let [suffix (first (shuffle suffixes))
new-prefix [(last prefix) suffix]
results-with-spaces (chain->text results)
results-char-count (count results-with-spaces)
suffix-char-count (inc (count suffix))
new-results-char-count (+ results-char-count suffix-char-count)]
(if (>= new-results-char-count 140)
results
(recur new-prefix chain (conj results suffix)))))))
;VS
(defn walk-chain
[prefix chain results]
(let [suffixes (get chain prefix)]
(if (empty? suffixes)
results
(let [suffix (first (shuffle suffixes))
new-prefix [(last prefix) suffix]
results-with-spaces (chain->text results)
results-char-count (count results-with-spaces)
suffix-char-count (inc (count suffix))
new-results-char-count (+ results-char-count suffix-char-count)]
(if (>= new-results-char-count 140)
results
(recur new-prefix chain (conj results suffix)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.