It is the same answer as before, I am afraid. The path to adding :join is also the path to adding :intersperse, and :sum, and :product, etc. We should have a general mechanism for expressing those, instead of individual options.
And, as before, a joiner does not really work well with into and reduce. *José Valimhttps://dashbit.co/ <https://dashbit.co/>* On Fri, Nov 15, 2024 at 11:06 AM Christian Blavier <cblav...@gmail.com> wrote: > Hey there, > > I'm still thinking about extending comprehension. What about a `then` > option? > > for i <- 1..3, do: i, then: &Enum.sum/1 > > for s <- ~w(a b c), do: s, then: &Enum.join(&1, ", ") > > (I know this can be achieved more efficiently with a reduce, but sometimes > concise syntax is a better choice) > > Le mardi 21 juin 2022 à 18:40:46 UTC+2, José Valim a écrit : > >> 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. >> >> On Tue, Jun 21, 2022 at 6:15 PM Christian Blavier <cbla...@gmail.com> >> wrote: >> >>> 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 >>> >>> -- >>> 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 >>> <https://groups.google.com/d/msgid/elixir-lang-core/f8b94dec-35a1-4b78-a14c-6913c7206fe3n%40googlegroups.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 visit > https://groups.google.com/d/msgid/elixir-lang-core/736e38fd-e0dd-4489-b079-73c116b5ecb7n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/736e38fd-e0dd-4489-b079-73c116b5ecb7n%40googlegroups.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 visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JEM%3DUD70e%2BpNXyKQqNxMB_gZnMbj%2By8ZH7tTr6rO5ahQ%40mail.gmail.com.