Re:The Comprehensive Guide to Elixir's List Comprehension (2...
by square_usual on Wednesday June 28, 2023 @08:37PM
(#36514808)
I agree with you: I prefer map and reduce unless I specifically need a comprehension because of multiple input collections. IMO for with many conditions etc. becomes too hard to understand, and you have to keep too many things in mind vs. a filter |> map. Regardless, I don't mind its presence, and it definitely has come in handy at times. Yet another reason to enjoy Elixir's approach to language design!
Re:The Comprehensive Guide to Elixir's List Comprehension (2...
by bluesnowmonkey on Thursday June 29, 2023 @11:01AM
(#36521328)
I also use ‘for’ rarely. It silently ignore list elements that don’t match, whereas ‘map’ or ‘each’ blow up. Generally I prefer things to blow up rather than fail silently.
The map approach feels a lot more functional to me and is easy to chain. The `for` method feels a bit awkward. But that said I much prefer Ruby to Python. If I had the opposite preference, I'd probably like the `for` in Elixir more.