<div dir="ltr"><div><div><div>I missed this thread, but Björn-Egil you know what I want. :-)<br><br></div>maps:first(Map) -> {Key,Value} | error.<br></div>maps:next(Key, Map) -> {Key,Value} | error.<br><br></div>Robert<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 April 2016 at 15:40, Björn-Egil Dahlberg XB <span dir="ltr"><<a href="mailto:bjorn-egil.xb.dahlberg@ericsson.com" target="_blank">bjorn-egil.xb.dahlberg@ericsson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    There is currently no (good) way to get out of C-context to execute
    some erlang snippet and then get back into c-context. Traps does
    this but only in a controlled manner. I think it is doable though.<br>
    <br>
    Your proposal of maps_apply/3 is the maps equivalent of
    dict:update/3 and sadly that name is already occupied in maps (it's
    the equivalent of gb_trees).<br>
    <br>
    I think we should add it to the API without thinking about the
    performance too much. Performance can always be improved later on.<br>
    <br>
    Is maps:apply/3 the best name we can think of? I don't really trust
    you and naming things. =) update/3,4 would probably have been best
    but c'est la vie.<span class="HOEnZb"><font color="#888888"><br>
    <br>
    // Björn-Egil</font></span><div><div class="h5"><br>
    <br>
    <div>On 2016-04-13 13:09, Jesper Louis
      Andersen wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      
      <div dir="ltr">
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Fri, Apr 8, 2016 at 8:31 PM,
            Björn-Egil Dahlberg <span dir="ltr"><<a href="mailto:wallentin.dahlberg@gmail.com" target="_blank"></a><a href="mailto:wallentin.dahlberg@gmail.com" target="_blank">wallentin.dahlberg@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Have you
              repeated some code or built your own private lib to handle
              certain maps specific tasks and thought "why isn't this in
              the maps module?"</blockquote>
          </div>
          <br>
        </div>
        <div class="gmail_extra">One function I like to have is "apply
          update via function", and I implement it somewhat often:<br>
          <br>
        </div>
        <div class="gmail_extra">maps_apply(F, K, Map) -><br>
        </div>
        <div class="gmail_extra">    V = maps:get(K, Map),<br>
        </div>
        <div class="gmail_extra">    maps:put(K, F(V), Map).<br>
          <br>
        </div>
        <div class="gmail_extra">But it can be made much faster in a
          direct implementation since I don't have to first pick up the
          value: I can apply F when I sit with the value at hand and
          thus avoid the "put" lookup path. It might, however, be nasty
          to implement because F is in Erlang-context, whereas the maps
          operations are in BIF-context.<br>
        </div>
        <div class="gmail_extra"><br clear="all">
          <br>
          -- <br>
          <div>J.</div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><span class=""><pre>_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </span></blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>