Last active
August 29, 2015 13:57
-
-
Save juanibiapina/9667394 to your computer and use it in GitHub Desktop.
This file contains 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
(def :f (function [:x] { (some-other-function x) } )) | |
(def :collatz (function [:n] { (if (= n 1) | |
{ (cons 1 nil) } | |
{ (cons n | |
(if (even? n) | |
{ (collatz (/ n 2)) } | |
{ (collatz (+ (* 3 n) 1)) } )) } ) | |
} )) | |
(def :collatz-size (function [:n] { (let [:helper { (function [:n :size] | |
(if (= n 1) | |
{ (+ 1 size) } | |
{ (helper (if (even? n) | |
{ (/ n 2) } | |
{ (+ (* 3 n) 1) } ) | |
(+ size 1)) } )) | |
} ] | |
{ (helper n 0) } ) | |
} )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment