[erlang-questions] Bound(?) var in anonymous fun
Tue Dec 18 12:12:06 CET 2012
Have a look at lists module . Maybe it worth to use existing functions?
On Tue, Dec 18, 2012 at 3:08 PM, Manuel A. Rubio "Bombadil" <
> Hi Pablo,
> El 2012-12-18 11:54, Pablo Vieytes escribió:
> I guessed Key was bound so I could use for pattern matching. It's
>> very easy to fix it but I don't know why it doesn't work.
> This doesn't works well because the params are not inside of binding in
> closures. The params are the interface with the outside world and will be
> confuse know if a param is a binding or not. By default Erlang hasn't
> binding in function params.
> Fixed version:
>> delete_key_from_list(Key, StatusList)->
>> fun(K, Acc) when K == Key ->
>> (Another, Acc) ->
> This code could be writted as:
> delete_key_from_list(Key, StatusList)->
> lists:filter(fun(X) -> Key =/= X end, StatusList).
> Manuel Rubio.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions