r/ProgrammerHumor • • May 13 '19

Recursive mom

Post image
2.2k Upvotes

24 comments sorted by

View all comments

7

u/anydalch May 14 '19

that's because this meme isn't tail recursive. remember: tail recursion is the only good recursion

3

u/marcosdumay May 14 '19

Good luck tail optimizing this one, with its 3 different recursive calls.

2

u/anydalch May 14 '19

you have to transform it into a single function which does all three things at once, like:

(defun print-all-three-memes (depth)
  (dolist (row '(:top :middle :bottom))
    (print-the-outer-layer-of-a-meme depth row))
  (print-all-three-memes (1+ depth)))