<div dir="ltr"><br><div style>I have to get used to use list comprehension. I know how it works but I never remember use it. </div><div style><br></div><div style><br></div><div style><br></div><div style><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2012/12/18 Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This one only removes the first element. :)<div class="im"><br>
<br>
On 12/18/2012 12:34 PM, Max Bourinov wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Or even more shooter:<br>
<br>
lists:delete(Key, StatusList).<br>
<br>
<br>
On Tue, Dec 18, 2012 at 3:22 PM, Dmitry Klionsky <<a href="mailto:dm.klionsky@gmail.com" target="_blank">dm.klionsky@gmail.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:dm.klionsky@gmail.com" target="_blank">dm.klionsky@gmail.com</a>><u></u>> wrote:<br>
<br>
On 12/18/2012 02:08 PM, Manuel A. Rubio "Bombadil" wrote:<br>
<br>
Hi Pablo,<br>
<br>
El 2012-12-18 11:54, Pablo Vieytes escribió:<br>
<br>
I guessed Key was bound so I could use for pattern matching.<br>
It's<br>
very easy to fix it but I don't know why it doesn't work.<br>
<br>
<br>
This doesn't works well because the params are not inside of<br>
binding in closures. The params are the interface with the<br>
outside world and will be confuse know if a param is a binding<br>
or not. By default Erlang hasn't binding in function params.<br>
<br>
Fixed version:<br>
<br>
delete_key_from_list(Key, StatusList)-><br>
lists:foldr(<br>
fun(K, Acc) when K == Key -><br>
Acc;<br>
(Another, Acc) -><br>
[Another|Acc]<br>
end,<br>
[],<br>
StatusList).<br>
<br>
<br>
This code could be writted as:<br>
<br>
delete_key_from_list(Key, StatusList)-><br>
lists:filter(fun(X) -> Key =/= X end, StatusList).<br>
<br>
Regards,<br>
Manuel Rubio.<br></div></div>
______________________________<u></u>___________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a> <mailto:<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@<u></u>erlang.org</a>><br>
<a href="http://erlang.org/mailman/__listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/__<u></u>listinfo/erlang-questions</a><div class="im"><br>
<<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a>><br>
<br>
<br>
Or even more readable as:<br>
<br>
delete_key_from_list(Key, StatusList)-><br>
[Status || Status <- StatusList, Status =/= Key].<br>
<br>
--<br>
Best regards,<br>
Dmitry Klionsky<br>
<br>
<br></div>
______________________________<u></u>___________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a> <mailto:<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@<u></u>erlang.org</a>><br>
<a href="http://erlang.org/mailman/__listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/__<u></u>listinfo/erlang-questions</a><br>
<<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a>><div class="im"><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
<br>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Loïc Hoguin<br>
Erlang Cowboy<br>
Nine Nines<br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a></font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>