[Proposal] Add :join to comprehensions

40 views
Skip to first unread message

Christian Blavier

unread,
Jun 21, 2022, 12:15:16 PM6/21/22
to elixir-lang-core

Do you think a join option would be a good idea for comprehensions?
Something like Enum.map_join/2 that could map and join lists in a single pass.

book_ids = for book <- books, join: ",", do: book.id

If it looks like a good idea, I will open a PR.

Best,

Christian

José Valim

unread,
Jun 21, 2022, 12:40:46 PM6/21/22
to elixir-lang-core
It should probably be done with using `into: joiner(",")`, where the joiner implements the collectable protocol. join itself probably doesn't make much sense because it doesn't play well with other options such as :into itself, or :reduce.

--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/f8b94dec-35a1-4b78-a14c-6913c7206fe3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages