jackpot@lemmy.ml to Programming@programming.dev · 11 months agowhen is it best to use a recursive function vs a for loopmessage-squaremessage-square26fedilinkarrow-up18arrow-down10
arrow-up18arrow-down1message-squarewhen is it best to use a recursive function vs a for loopjackpot@lemmy.ml to Programming@programming.dev · 11 months agomessage-square26fedilink
minus-squarecoloredgrayscale@programming.devlinkfedilinkarrow-up1·11 months agoA naive iterative implementation would be by adding and removing the folders/files from a list. If tail call optimization works on the (recursive) example then that’s (kinda) the compiler turning a recursive function into a loop.
A naive iterative implementation would be by adding and removing the folders/files from a list.
If tail call optimization works on the (recursive) example then that’s (kinda) the compiler turning a recursive function into a loop.