I like this new proposal a lot, it brings the power of map_reduce to
comprehensions without any need for new concepts to learn.

I was just wondering how it could be used from EEx/Phoenix templates,
looking at the previous example from Chris:

    <%= for item <- items, let: {highlighted? = false} do
      ...
      <% highlighted? = not highlighted? %>
    <% end %>

The let/reduce alternatives only offer the option to discard or not the
list, but will always return the accumulator (which forces to pattern-match
on a tuple if we just want the list). Maybe we could have an option to just
discard the accumulator and return the list (as in the template use case),
or maybe even another option to discard both and return :ok (to enable
Enum.each/2 like comprehensions)? Not sure what the API could look like.



Le mar. 21 déc. 2021 à 03:12, José Valim <jose.va...@dashbit.co> a écrit :

> Hi everyone,
>
> This is the second proposal for-let. You can find it in a gist:
> https://gist.github.com/josevalim/fe6b0bcc728539a5adf9b2821bd4a0f5
>
> Please use the mailing list for comments and further discussion. Thanks
> for all the feedback so far!
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KHhMO3cFzf3L%3D7e1EJbC8hu5bLFUA%2BTRSkb9iDGozUSQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KHhMO3cFzf3L%3D7e1EJbC8hu5bLFUA%2BTRSkb9iDGozUSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CANnyohZjcYP7V4yyWj%3D5ygVuqM3HSSPHqOmeLEgE3m2XPGk3bA%40mail.gmail.com.

Reply via email to