-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thinking loops in Elixir #75
Comments
Hi, you can still use
|
Heh, quite right @bossek! |
there is a reduce option in for loop , which can be treated as 3rd option acc = [] |
Updating the above example using 3 approach using loop reduce all_numbers = [4, 2, 5, 9, 6, 1, 0] for num <- all_numbers, reduce: even_numbers do |
I would add: multiple or zero elements. |
You also can loop using Enum.filter/2 (or Enum.filter(all_numbers, &rem(&1, 2) == 0) But underneath, it's all |
Thinking loops in Elixir
Approaches for converting imperative loops into functional Elixir.
https://alexpearce.me/2023/06/elixir-loops/
The text was updated successfully, but these errors were encountered: