<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    On 2016-04-20 16:38, Federico Carrone wrote:<br>
    <blockquote
cite="mid:CAMuJbHhmBf-HXC-bhC7QXzAF78c5DFfunzWksr1GmnBcWizKUw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">It would be awesome to have a a map iterator/map
        comprehension.</div>
    </blockquote>
    <br>
    Many are of the same opinion. However iterators are not in this
    scope. Only API additions to the maps module are.<br>
    Efficient iterators are necessary to implement efficient generators
    for maps. Efficient maps comprehension is whole other ballgame.<br>
    <br>
    I will post a PR of maps:take/2 and maps:apply/3,4 later this week.
    I'm not sure about apply .. or it's name.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAMuJbHhmBf-HXC-bhC7QXzAF78c5DFfunzWksr1GmnBcWizKUw@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">
        <div dir="ltr">On Tue, Apr 19, 2016 at 5:30 PM Robert Virding
          <<a moz-do-not-send="true" href="mailto:rvirding@gmail.com">rvirding@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <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>
          </div>
          <div dir="ltr">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
                  moz-do-not-send="true"
                  href="mailto:bjorn-egil.xb.dahlberg@ericsson.com"
                  target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:bjorn-egil.xb.dahlberg@ericsson.com">bjorn-egil.xb.dahlberg@ericsson.com</a></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><font
                      color="#888888"><br>
                      <br>
                      // Björn-Egil</font></span>
                  <div>
                    <div><br>
                      <br>
                      <div>On 2016-04-13 13:09, Jesper Louis Andersen
                        wrote:<br>
                      </div>
                    </div>
                  </div>
                  <blockquote type="cite">
                    <div>
                      <div>
                        <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 moz-do-not-send="true"
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>
                      <pre>_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" 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 moz-do-not-send="true"
                  href="mailto:erlang-questions@erlang.org"
                  target="_blank">erlang-questions@erlang.org</a><br>
                <a moz-do-not-send="true"
                  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>
          _______________________________________________<br>
          erlang-questions mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
          <a moz-do-not-send="true"
            href="http://erlang.org/mailman/listinfo/erlang-questions"
            rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>