[erlang-questions] anyway to make recursion inside anonymous funs?

ok ok@REDACTED
Fri Mar 30 03:08:00 CEST 2007


On 29 Mar 2007, at 9:09 pm, Håkan Huss wrote:
> Well, obviously we don't *have to* give G a name, or lambda-calculus
> would have severe problems. Not doing so, however, requires you to
> write out the fun previously known as G twice:
> F = fun (N) ->
>            fun (_, 0) -> 1;
>                (G, N) -> N * G(G, N-1)    %%<<<<<<<
>            end
>              (fun (_, 0) -> 1;
>                   (G, N) -> N * G(G, N-1) %%<<<<<<<
>               end,
>               N)
>    end.

But in this example he HAS given G a name, in the lines I have flagged
with %%<<<<<<<.  Even that, of course, can be eliminated by using
combinators, but if we were going to use combinators we might as well
use Y and be done with it.





More information about the erlang-questions mailing list