In the example the
D(L)displays the elements in the list
1> D = fun(F, ) -> ok; 1> (F, [H|T]) -> io:format("~p~n", [H]), F(F,T) end. #Fun<erl_eval.12.82930912> 2> D(D, [a,b,c]). a b c okIf the binding takes place before the function definition, we could have written like
1> G = fun() -> ok; 1> ([H|T]) -> io:format("~p~n", [H]), G(T) end. * 2: variable 'G' is unboundbut, we can see that it gives an error. This is similar to a fixed-point combinator like a Y combinator.