Skip to content

Instantly share code, notes, and snippets.

@hierophantos
Created January 20, 2019 04:30
Show Gist options
  • Save hierophantos/c7972c48514a63d2e997d2ee41eb8a20 to your computer and use it in GitHub Desktop.
Save hierophantos/c7972c48514a63d2e997d2ee41eb8a20 to your computer and use it in GitHub Desktop.
(defn logistic [x r n]
(loop [x x
n n
xs []]
(if (= n 0) xs
(recur (* r x (- 1 x))
(dec n)
(conj xs x)))))
(defn logistic-rec [x r n]
(_logistic-rec x r n []))
(defn _logistic-rec [x r n acc]
(if (= n 0) acc
(let [new-x (* r x (- 1 x))]
(_logistic-rec new-x r (dec n) (conj acc x)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment