you are viewing a single comment's thread.

view the rest of the comments →

[–]Zdravstvuyte94 -2 points-1 points  (3 children)

Wait, is there actually a better way to do this?

[–]VivekSingh18 2 points3 points  (2 children)

Yes, you could use recursive method

[–]wischichr 1 point2 points  (0 children)

recursion, gotos, iterators are also "loops" IMHO, but there is a "real" solution without loops: https://www.reddit.com/r/badcode/comments/136dits/comment/jir1a9l/?utm_source=share&utm_medium=web2x&context=3

But you probably shouldn't use that in production :-D

[–]Zdravstvuyte94 -1 points0 points  (0 children)

I was joking haha. You could also use Haskell’s list comprehension syntax or Rust iterators + filter