Hacker News new | ask | show | jobs
by PKop 1093 days ago
Elixir doesn't have for loops
1 comments

    for x <- 1..10 do
      IO.puts x
    end
Isn't that a for loop?
Similar, but different in subtle ways when you get beyond the toy example posted here...particularly that it's always iterating a collection, vs being able to just arbitrarily loop based on arbitrary conditions..where you'd be able to easily break out of it, modify a mutable collection within it etc

https://dev.to/brewinstallbuzzwords/does-elixir-have-for-loo... "Does Elixir have for loops?"

https://elixirforum.com/t/changing-variables-in-a-loop/43526 "Changing variables in a loop"

https://stackoverflow.com/questions/56196664/better-way-writ...

https://stackoverflow.com/questions/48178773/adding-items-to...

In Elixir that is a called a comprehension, just like the blog post is discussing.