[Haskell-beginners] recursive 'let' ?
magnus at therning.org
Fri Apr 11 15:28:15 UTC 2014
On Thu, Apr 10, 2014 at 07:12:25PM -0500, John M. Dlugosz wrote:
> I understand that the definitions introduced by 'let' can be
> recursive, even mutually recursive among several names. Why would
> you want to do that? I saw contrived examples, and wonder why the
> authors never show a realistic example.
> let b = f a c
> c = f a b
> in ...
> I see that makes sense in light of lazy evaluation: b is really an
> alias for a (recursive) function, not a value that needs to find
> fixed points.
> Is this used for common idioms and problem-solving approaches in
I can't really point to any idiomatic use, or problem-solving
approaches, but it is a terribly useful feature since one of the
effects is that the order of introducing functions/values isn't
significant. So you are free to write and structure your code in the
manner that makes most sense to you.
Having just ventured back into OCaml and dipping my toes in F# I
immediately ran into errors caused by their non-recursive `let`, and
the requirement to introduce values/types before use.
Magnus Therning OpenPGP: 0xAB4DFBA4
email: magnus at therning.org jabber: magnus at therning.org
twitter: magthe http://therning.org/magnus
The results point out the fragility of programmer expertise: advanced
programmers have strong expectations about what programs should look like,
and when those expectations are violated--in seemingly innocuous
ways--their performance drops drastically.
-- Elliot Soloway and Kate Ehrlich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
More information about the Beginners