Timeline for Clojure Fibonacci
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 19, 2014 at 16:06 | comment | added | Mars |
Thanks abuzittin gillifirca--I didn't know that about recursion in a function defined in a let. I don't consider it a new answer, though--only a stylistic variant on your answer.
|
|
| Dec 19, 2014 at 7:30 | comment | added | abuzittin gillifirca |
Thanks @Mars, that would be an excellent new answer. In the comments, though, it is not nearly visible enough. One minor point to fix in your new answer: In order to define a recursive function in let bindings we'd need a named fn expression as in (let [lazyFib (fn lazyFib [a b] ...)], because left hand side of a binding is not yet available to the right hand side in let.
|
|
| Dec 19, 2014 at 3:49 | comment | added | Mars |
Sobieck00, an alternative to (letfn [(lazyFib ...)] ...) is (let [lazyFib (fn [a b] ...)] ...). In this case, I would use letfn, as abuzittin gillifirca, suggests, but when I have to combine a local function definition with other local definitions, sometimes I use let, because it makes the code slightly more concise. This is probably a a matter of personal preference, however.
|
|
| Dec 17, 2014 at 17:04 | vote | accept | Thomas Sobieck | ||
| Dec 17, 2014 at 16:09 | history | answered | abuzittin gillifirca | CC BY-SA 3.0 |