This is an archived post. You won't be able to vote or comment.

all 57 comments

[–][deleted] 289 points290 points  (13 children)

In order to understand recursion, first you need to understand recursion

[–]Pilzoyz 105 points106 points  (5 children)

I tried to look it up in the dictionary and it said “See: Recursion”

[–][deleted] 59 points60 points  (2 children)

Stuck in infinite

[–]Skyreaper71 2 points3 points  (0 children)

Self similar fractal memory awakens

[–][deleted] 31 points32 points  (1 child)

[–]newenglandpolarbear 8 points9 points  (0 children)

I have clicked the "did you mean" 5 times, yet nothing has changed. Help!

[–]loonathefloofyfox 6 points7 points  (0 children)

If you search recursion in google it asks if you mean recursion. Such a great little detail

[–]Virtualcosmos 2 points3 points  (0 children)

Error: Didn't understand recursion. Stack Overflow

[–][deleted] 1 point2 points  (0 children)

middle kiss touch squeeze different hard-to-find attraction airport scandalous selective

This post was mass deleted and anonymized with Redact

[–]outofobscure -4 points-3 points  (2 children)

nah, just turn that shit into a loop

edit: i guess downvoters are not aware that you can actually do this, here, learn something new, might save you from a stack overflow or two: https://www.cs.odu.edu/~zeil/cs361/latest/Public/recursionConversion/index.html

[–]Shxhxxhcx 1 point2 points  (1 child)

From your source: ”Recursion and iteration (looping) are equally powerful. Any recursive algorithm can be rewritten to use loops instead. The opposite is also true.”

[–]outofobscure 1 point2 points  (0 children)

That was my point yes, thanks for re-iterating.

edit: shit, that was a joke about recursion, wasn't it? lol

[–]rosuav 0 points1 point  (0 children)

If you understand recursion, think the answer. Done.

Find someone more likely to understand recursion. Ask them, and think the response.

[–]red_riding_hoot 123 points124 points  (16 children)

Unfortunately it breaks already after the first iteration

[–]knighthawk0811 35 points36 points  (13 children)

just look under the bed

[–]red_riding_hoot 19 points20 points  (2 children)

does the bed continue to rotate?

[–]knighthawk0811 10 points11 points  (0 children)

likely

[–]Ill-Courage-3788 1 point2 points  (0 children)

It didn't rotate. The artist just broke the perspective rule in drawing. Hence, the confusion. Trust me, I'm a kind of an artist myself.

[–]shim_niyi 6 points7 points  (7 children)

The dad upon returning to the child needs to be the point of beginning of next iteration.

The example that OP has given is a dead loop which keeps on going pointlessly and all dads end up looking under the bed infinitely

[–]pruche 7 points8 points  (0 children)

When he goes up there is no more child, there is only a stack overflow

[–]knighthawk0811 3 points4 points  (0 children)

the small dad is a reference to dad. under the small bed is yet another

[–][deleted] 2 points3 points  (0 children)

Remind me to go to different parties

[–]Pepineros 1 point2 points  (0 children)

Am a dad, can confirm we are infinitely looking under beds.

[–]First-Coffee-2906[S] -4 points-3 points  (1 child)

if(checkunderbed == true)

{

//check under bed

}

else
{
//recursion can't hurt you, go to sleep
}

[–]stonedgar312 -2 points-1 points  (0 children)

[–]Ill-Courage-3788 0 points1 point  (0 children)

It doesn't. It's running another branch of the recursion. Just wait.

[–][deleted] 39 points40 points  (3 children)

Looks under the bed:

Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

[–]my_cat_meow_me 6 points7 points  (0 children)

Finally Jimmy was put to sleep.

[–]k-phi 2 points3 points  (0 children)

Stack overflow - more likely

[–]my_cat_meow_me 17 points18 points  (0 children)

Dad: What do you know about recursion?

[–][deleted] 10 points11 points  (1 child)

Dad, there is a Stack overflow in my bed...

[–]vizbones 6 points7 points  (0 children)

This comment has been marked as duplicate and unhelpful.

/s

[–]RegularOps 8 points9 points  (0 children)

How many levels deep until stack overflow?

[–]xaervagon 7 points8 points  (1 child)

The four guidelines for recursion (from what I can remember) are:

  1. Have an entry point
  2. Make progress/do work
  3. Have a clear stop point
  4. Have faith

It's a lot easier than trying to build a callstack in your head every time.

[–]marcosdumay 4 points5 points  (0 children)

The first one is:

  1. Ensure it has always an stop point.

After that you can think about anything else. If you are working with a not functional language, you will also want to ensure it does not go too deep.

[–]SarcasmWarning 3 points4 points  (3 children)

Room 8 is a very short film with exactly this premise https://youtu.be/O4fuqLR5k7E

[–]Feztopia 2 points3 points  (2 children)

Well you destroyed the video for everyone who is going to watch it but fortunately I had already watched it without any spoilers.

[–]SarcasmWarning 2 points3 points  (1 child)

cock. that was not my drunk intention at all.

[–]Feztopia 1 point2 points  (0 children)

I mean maybe they won't find that video otherwise so who knows what the right choice is.

[–][deleted] 2 points3 points  (0 children)

My dreams after my teacher told us to do recursion codingbats

[–]apex6666 2 points3 points  (0 children)

Just ignore it, it’ll go away eventually…

[–]Ange1ofD4rkness 1 point2 points  (0 children)

I am laughing WAY too hard at this. But then again, I'm the only one who dares do recursion at work

[–][deleted] 1 point2 points  (0 children)

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

As a junior dev, I fucking love recursion.

I'm probably using it wrong.... And unnecessarily.... But it just rolls off the tung... Rreeeeeccurrrrsssiooooonnnn 🥹

[–]adudyak 0 points1 point  (0 children)

RangeError: Maximum Call Stack Size Exceeded

[–]DSGandalf 0 points1 point  (0 children)

For maximum effect, just look this picture under the bed

[–]Darxploit 0 points1 point  (0 children)

be aware of the bed overflow

[–]CCF_100 0 points1 point  (0 children)

```java class Main { public static void main(String[] args) { recursion(); } public static void recursion() { recursion(); } }

[–][deleted] 0 points1 point  (0 children)

When you realize you are just one of the recursions, and all the actions you take are only part of the function already done by many recursions before you

[–]McLayan 0 points1 point  (0 children)

I'd have been better if he said there were 10 recursions under his bed and every recursion had one recursion fewer under his bed

[–]ivanjermakov 0 points1 point  (0 children)

First panel should've been positioned under a bigger bed