[erlang-questions] re cursive fun()
Mon Oct 6 17:34:21 CEST 2008
the example I gave was not suppose to be a practical one, I just wanted to
ask how to recursively call a anonymous function...
Richard O'Keefe wrote:
> On 5 Oct 2008, at 4:19 pm, deepblue_other wrote:
>> I have this going on
>> FunVar =
>> fun() ->
> Shouldn't this go in a FAQ somewhere?
> Maybe it belongs in the reference manual.
> The quick answer is that if you need a recursive
> function, why not write a recursive function in the
> usual way?
> There's something particularly nasty about this
> example. One normally proves (or at any rate
> argues with vigourously waving hands for) the
> termination of a recursive function by showing
> that some non-negative measure of its arguments
> strictly decreases on each recursive call, but
> this function has no arguments. I think we need
> to see more of it.
> The long answer is that you can always do
> Rec = fun (Self, Args) ->
> Self(Self, Args')
> Foo = fun (Args) -> Rec(Rec, Args) end,
> It's possible, but you are working against the
> grain of the language, and there is most likely
> a better way to achieve your goals.
> erlang-questions mailing list
View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19840331.html
Sent from the Erlang Questions mailing list archive at Nabble.com.
More information about the erlang-questions