Hi clojure-world,
I think maybe this is actually related to the complexities of binding
referenced in the previous thread
(https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/clojure/zBXsrqTN2xs)...
maybe? But it would be amazing if some wise person would help explain.
Note that letfn does allow recursive bindings, though I couldn't comment as
to the implementation details.
On Friday, December 2, 2016 at 3:01:13 PM UTC-5, Paul Gowder wrote:
>
> Hi clojure-world,
>
> I think maybe this is actually related to the complexities of binding
> referenced in the prev
Let bindings are immutable bindings, not refs. They must act as if their value
could be substituted at the moment they are referenced. Def (i.e. a ref) is a
mutable container whose contents is examined when it is used (not when
referenced), which is why your second example works.
Why doesn't l
AFAIK there are two options.
You can add a symbol after fn:
(let [fib (fn y [x]
(cond
(< x 2) x
:else (+ (y (- x 2)) (y (- x 1)]
(fib 5))
Or, as Bobby already suggested, you can use letfn:
(letfn [(fib [x]
(cond
(<
Thanks Bobby, Francis, Walter! Now trying to wrap my head around the idea
of def as a ref...
On Friday, December 2, 2016 at 2:57:13 PM UTC-6, Francis Avila wrote:
>
> Let bindings are immutable bindings, not refs. They must act as if their
> value could be substituted at the moment they are re
Your "y" could also be "fib". You are permitted to use the same name
inside the fn.
On Fri, Dec 2, 2016 at 12:59 PM, Walter van der Laan <
waltervanderl...@gmail.com> wrote:
> AFAIK there are two options.
>
> You can add a symbol after fn:
>
> (let [fib (fn y [x]
> (cond
>