@jackpot@lemmy.ml to Programming@programming.dev • 7 months agowhen is it best to use a recursive function vs a for loopmessage-square50fedilinkarrow-up132
arrow-up132message-squarewhen is it best to use a recursive function vs a for loop@jackpot@lemmy.ml to Programming@programming.dev • 7 months agomessage-square50fedilink
minus-square@cosmicrose@lemmy.worldlinkfedilinkEnglish6•6 months agoIn Elixir & Erlang, they don’t even have a for-loop construct. You have to use recursion. And I think that’s beautiful. I also think tail-call optimization is beautiful.
minus-square@glitches_brew@lemmy.worldlinkfedilink5•edit-26 months agoElixir does have for loops. https://hashrocket.com/blog/posts/elixir-for-loops-go-beyond-comprehension That being said, I have worked at a company who uses Elixir 4 years now and I have never once written one.
minus-square@cosmicrose@lemmy.worldlinkfedilinkEnglish3•6 months agoOh you’re so right, I never use those so I completely forgot :X
In Elixir & Erlang, they don’t even have a for-loop construct. You have to use recursion. And I think that’s beautiful. I also think tail-call optimization is beautiful.
Elixir does have for loops.
https://hashrocket.com/blog/posts/elixir-for-loops-go-beyond-comprehension
That being said, I have worked at a company who uses Elixir 4 years now and I have never once written one.
Oh you’re so right, I never use those so I completely forgot :X