r/badcode • • Jan 01 '19

[deleted by user]

[removed]

138 Upvotes

87 comments sorted by

View all comments

Show parent comment

2

u/MoldyWolf Jan 02 '19

I'm pretty sure using recursion to go through elements of an array is pretty inefficient

2

u/Tynach Jan 02 '19

Just depends on how the compiler optimizes it. If you have tail-call optimization, you can write recursive code that gets compiled into a loop.

1

u/MoldyWolf Jan 02 '19

Oh yeah I see what you're saying