<div dir="ltr">In case someone finds it useful; Sergej's implementations of mapstore/mapfind are available on github (bkdcore / butil module):<div><br></div><div><a href="https://github.com/biokoda/bkdcore/blob/master/src/butil.erl">https://github.com/biokoda/bkdcore/blob/master/src/butil.erl</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-23 16:26 GMT+01:00 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">I would +1 that. A tuple list and a map list are two different things, and it would be very unusual to see one with both.<br>
<br>
Also would like to add that as they are operating on different types there should be separate functions (mapfind and mapstore are indeed good names).<span class=""><br>
<br>
On 11/23/2014 05:04 PM, Sergej Jurecko wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
I just converted a ~5k lines of code project into using maps. I wrote<br>
myself mapfind(Key,Value,L) and mapstore(Key,Val,L,Map). That was all I<br>
needed. I did not care about compatibility with other types in list.<br>
<br>
Is worrying about mixing tuples/records with maps in a list really<br>
necessary? In the 6+ years of writing erlang, I don’t think I’ve had a<br>
list of mixed types more than a couple of times.<br>
<br>
<br>
Sergej<br>
<br>
On 23 Nov 2014, at 15:43, Lukas Larsson <<a href="mailto:lukas@erlang.org" target="_blank">lukas@erlang.org</a><br></span>
<mailto:<a href="mailto:lukas@erlang.org" target="_blank">lukas@erlang.org</a>>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hello,<br>
<br>
I agree with you that in certain situations they would be very<br>
convenient. I've myself already written these functions in a couple of<br>
modules.<br>
<br>
How do you imagine the semantics would work? It is fairly straight<br>
forward when the list only contains maps or tuples.<br>
<br>
lists:keyfind(you, name, [#{ name => me, from => here }, #{ name =><br>
you, from => there}]) returns #{ name => you, from => there}.<br>
<br>
But if we start to mix them some interesting corner cases pop up:<br>
<br>
lists:keyfind(2, 1,[#{ 2 => 3 },{2, 4},#{ 1 => 2 } ]) returns {2,4} or<br>
#{ 1 => 2 }?<br>
lists:keyfind(1, id, [{1,2}, #{ id => 2}, #{ id => 1}) returns #{ id<br>
=> 1 } or crashes as id is not a valid key for {1,2}?<br>
<br>
Or error cases of today:<br>
<br>
lists:keyfind(2, id, []) today gives badarg, but should return false<br>
for a map list?<br>
<br>
The safest way to introduce these functions would be to create new<br>
ones called something like lists:mkeyfind, but if possible it would be<br>
very neat to use the same API. It really is unfortunate that<br>
lists:keyfind is so forgiving today, you can mix and match whatever<br>
you want in the list and keyfind will quietly ignore it.<br>
<br>
Also we have to consider which of the lists:key* functions we want a<br>
map counterpart? Does it make sense for all of them?<br>
<br>
Thoughts? Ideas? Suggestions?<br>
<br>
Lukas<br>
<br>
<br>
On Sat, Nov 22, 2014 at 7:33 PM, John Doe <<a href="mailto:donpedrothird@gmail.com" target="_blank">donpedrothird@gmail.com</a><br></div></div><span class="">
<mailto:<a href="mailto:donpedrothird@gmail.com" target="_blank">donpedrothird@gmail.<u></u>com</a>>> wrote:<br>
<br>
It would be nice to extend lists module with a set of optimized<br>
functions like lists:key*** for lists containing maps.<br>
<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br></span>
<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>><span class=""><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>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
</span><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>
</blockquote><span class="">
<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>
</span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Loïc Hoguin<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><br clear="all"><div><br></div>-- <br><div class="gmail_signature">
<p><span style="color:rgb(153,153,153)">Denis Justinek - @: </span><a href="mailto:denis.justinek@gmail.com" target="_blank">denis.justinek@gmail.com</a><span style="color:rgb(153,153,153)"> - www: </span><a href="http://about.me/djustinek" target="_blank">http://about.me/djustinek</a></p></div>
</div></div>