Skip to content

Instantly share code, notes, and snippets.

@dineybomfim
Created July 18, 2018 10:04
Show Gist options
  • Save dineybomfim/81e17fa80d92313d1877a1db93f5fdbc to your computer and use it in GitHub Desktop.
Save dineybomfim/81e17fa80d92313d1877a1db93f5fdbc to your computer and use it in GitHub Desktop.
func buildWords(with text: inout String, length: Int, chain: Matrix<String>) {
var word = text
(0...length).forEach { _ in
if let next = chain.next(given: word, process: .weightedRandom) {
text.append(" \(next)")
word = next
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment