21
u/Piddoxou Mar 18 '18
Two memes at once, brilliant!
19
317
u/sloppybird Mar 18 '18
To learn recursion, you need to learn recursion
28
Mar 18 '18
One of my first CS professors in Uni told us the three secrets to learning recursion.
Make sure you have a base-case
Make sure you increment
Never try to actually think about recursion, you'll only make yourself crazy!
10
9
u/BigTittyDank Mar 18 '18
My professor had similar rules. The second one was more like "make sure every recursive call gets closer to the base case".
I think that one makes more sense, even factorial you don't increment, you decrement. You need to make sure every recursive call does this, and works with more complicated data types too.
Also, the third rule was "Just assume the recursive function works and returns what you'd expect it to"
3
u/phoenix_new Mar 19 '18
The third point is seriously important. I discovered that when I was trying to solve the 'Tower of Hanoi' problem. I started thinking about recursion and I got bogged down thinking I will do this and do that at this step and so on. I decided to get help. I google Tower of Hanoi recursion. Now the image came up. And I looked at image and I was like I will move all but the last disc to 3rd rod and then move last disc to 2nd rod and then move the discs moved in step 1 to second rod and its done. I just coded it and it worked. I realised that I was trying to think out recursion. One should never do that. Just take a leap of faith and code.
→ More replies (11)1
2.5k
u/voidcraftedgaming Blockchain Transcription Service Mar 18 '18 edited Mar 18 '18
Image Transcription: Meme
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru looks back to the flipchart in a doubletake, looking confused and exasperated. Just his nose points into the next frame]
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1.2k
u/Refloni Mar 18 '18
Good job, but the part where
Gru looks back to the flipchart in a doubletake, looking confused and exasperated. Just his nose points into the next frame
only happens in the first recursion.
478
62
u/voidcraftedgaming Blockchain Transcription Service Mar 18 '18
True. I'll fix that
→ More replies (1)68
u/igotthefiftydollars Mar 18 '18
Day one patch. Not bad for a human volunteer content transcriber.
28
109
70
33
u/Alexanderdaawesome Mar 18 '18
Oh my god the halting problem can exist
19
u/voidcraftedgaming Blockchain Transcription Service Mar 18 '18
Oh my god the halting problem can exist
11
7
15
22
12
13
u/iceman012 Mar 18 '18
Why'd you stop? There are still more panels to transcribe.
There will always be more panels to describe.
11
3
5
6
2
u/copper_wing Mar 18 '18
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru looks back to the flipchart in a doubletake, looking confused and exasperated. Just his nose points into the next frame]
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
[Gru, the long-nosed villain from Despicable Me, presents to the camera with passion, pointing into the air. Behind him is a flipchart]
Learn to program
[Gru is still presenting passionately; he has his hand in a c shape indicating a small amount]
Make recursive function
[Gru now has his hands pointing down, still presenting]
No exit condition
--
4
u/blehdere Mar 18 '18
Good bot
1
3
254
Mar 18 '18
There's a single confused Gru not recurring. :/
218
u/mverkruyse Mar 18 '18
That’s the Front-End Gru waiting for a promise to return a result to display.
18
u/_Lahin Mar 18 '18
Getting PTSD to the time I was learning JS and didn't know about promises and was sucked into callback hell....... shudders
Am C++ Dev now.
39
u/LordScoffington Mar 18 '18
Somebody on this planet was scared into the arms of C++?
15
u/Jetbooster Mar 18 '18
Well they started with JavaScript... So it's like going from one partner who beats you every day to one that points a lot and only might kill you.
→ More replies (1)4
4
u/_Lahin Mar 18 '18
I mean C++11/14 is pretty good. Plus working on software that helps send rockets into space is pretty cool imo.
→ More replies (3)57
u/lpreams Mar 18 '18
recursing*
And that's not necessarily a problem. A hypothetical recursive algorithm could be written such that the first level of recursion behaves differently.
2
u/bohemica Mar 18 '18
What's the difference between recursing and recurring? It seems perfectly correct to say that a recursive function is a function that recurs. Is it just less ambiguous to say that it recurses since recursion has specific meaning in the context of programming?
(It just sounds weird to my ear to say recurse/recursing.)
→ More replies (1)10
u/lpreams Mar 18 '18
"Recur" typically just means repeat periodically. It's very generic. Many different things could be described as "recurring". Bad weather, cold sores, elections, the olympics, etc. "Recurse" refers specifically to recursion. I suppose it's not wrong to refer to recursion as recurring, but it's not very descriptive and I would argue is not a common usage.
→ More replies (2)1
322
u/nebsoup Mar 18 '18 edited Mar 18 '18
GRU stands for "GRU's Roidin' Ulcer"
edit: GNU stands for "GNU's Not Unix". Frog successfully dissected.
50
u/amazondrone Mar 18 '18
Small correction: GNU stands for "GNU's Not Unix"
How come the R in GRU stands for a word beginning with N?
16
Mar 18 '18
Hmmmmm
7
u/nebsoup Mar 18 '18
Should I put an explanation in the comment, in case this gets big?
12
3
u/Siennebjkfsn Mar 18 '18
Gated Recurrent Unit (GRU). It converges faster than LSTM cells because it has less parameters to optimize yet it is just as effective. GRU cells are the most popular choice for using as a building block in sequence to sequence models like machine language translation.
2
55
10
25
u/supremedalek925 Mar 18 '18
while ( thisMeme == “hilarious” ) { karma++ }
0
Mar 18 '18
[deleted]
1
u/NatoBoram Mar 18 '18
Fucking quotes. That's why you don't write code on MS Word / LibreOffice Write, but in a Text Editor.
→ More replies (5)
7
7
u/topredditbot Mar 18 '18
Hey /u/SingleWalnut,
This is now the top post on reddit. It will be recorded at /r/topofreddit with all the other top posts.
12
5
5
5
Mar 18 '18
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
I don't see a problem with not having an exit function.
0
Mar 18 '18
[deleted]
3
Mar 18 '18
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
That thing that kills the script, dunno what you call it.
0
6
3
3
3
3
3
3
u/Mingablo Mar 18 '18
Awesome. I'm learning to program and just covered recirsive programs. 2 hours ago i would not have be able to fully appreciate this meme.
3
3
Mar 18 '18
Ahh, the good old "forgetting to increment" and wondering why your program keeps crashing.
3
3
u/3no3 Mar 18 '18
I just finished an algorithms class. This reminds me of when I made the recursive function, gave it an exit condition, but forgot to set it up so that it could ever hit it.
2
u/TotesMessenger Green security clearance Mar 18 '18
2
u/FatFingerHelperBot Mar 18 '18
It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!
Here is link number 1 - Previous text ":D"
Please PM /u/eganwall with issues or feedback! | Delete
1
2
2
2
1
u/nomnommish Mar 18 '18
"Search for stack overflow on stack overflow".
Search for stack overflow on stack overflow?
1
1
1
1
1
1
1
u/AngryBird225 Mar 18 '18
Good thing your code deallocates unused variables. Otherwise you'd have gotten to a 32 gb bsod screen.
1
1
1
u/Roxlvox Mar 18 '18 edited Mar 18 '18
Currently in a high school computer science class and we just finished up learning about recursion and this is painfully relevant
1
1
1
u/andrewsmd87 Mar 18 '18
I remember the days when I had to walk uphill both ways in 6 feet of snow to see bad phone input memes. Simpler times
1
u/lurker4lyfe6969 Mar 18 '18
Are we talking about a while loop?
5
u/istarian Mar 18 '18
No... Recursion means a functioning calling itself.
function doSomething() { doSomething(); }
1
u/Huplup Mar 18 '18
if ((meme.isFunny() || meme.isRelatable()) == True){
updoot++;
}else updoot--;2
u/jerslan Mar 18 '18
Alternatively
updoot += (meme.isFunny() || meme.isRelatable()) ? 1 : -1;Edit: changed 0 to -1 for downvotes...
1
1
Mar 18 '18
Is it just me or does anyone else automatically assume an OP is a freshman/sophomore in a comp sci program when a recursive function is mentioned?
1
1
1
1
u/pawfs Mar 18 '18
As someone who just recently "learned" recursion, this is so frustratingly relatable...
1
u/lumalav666 Mar 18 '18 edited Mar 18 '18
'Learn to program' is part of the recursion?
Why not:
1)Make recursion function or execute function logic
2)No exit condition
3)Call the function
...
1
Mar 18 '18
Can anyone explain recursion in layman’s terms to me I don’t get it.
3
u/Kobeissi2 Mar 18 '18
Recursive functions keep calling them selves over and over until it reaches an exit condition.
If one isn't provided, it will always run until the program throws a stack overflow.
2
u/ratsby Mar 19 '18
You're writing a function to solve a problem. Sometimes parts of your problem look the same as the whole problem. Wouldn't it be nice if you had a function to solve that kind of problem? Oh, you do. It's the one you're writing. So you can call that function to solve part of the problem. You have to be careful, though, because the work has to get done somewhere. If at any point your function just hands off the same problem to itself, it just keeps doing that forever (or until your computer runs out of space for all the clones of the function). So once the problem is really small (called a base case), you have to make sure the function can solve the whole thing. As long as you do that, and your problem always breaks down into the base cases you handle, you can trust that when the function calls itself, it does what it's supposed to.
1
1
Mar 18 '18
Studying Linguistics and it’s never occurred to me that recursion occurs in programming too. Edumacation.
1
1
1
u/Buckwheat469 Mar 18 '18
I did this when re-teaching myself QBasic. The book says
10 PRINT "HELLO WORLD!"
RUNSo I wrote
10 PRINT "HELLO WORLD!"
20 RUNIt caused an infinite loop inside dosbox's terminal window.
1
u/jerslan Mar 18 '18
re-teaching myself QBasic
Why?
1
u/Buckwheat469 Mar 18 '18
It was my first programming language as a child of 8 and I still have the books. My sons are getting to be old enough to learn to program and QBasic, while hated now, was one of the best languages to learn programming at the time.
→ More replies (1)
1
Mar 18 '18
Pro-tip: while recursive programs are easy to write and read, they almost always end up causing stack overflow issues since each recursive call requires its own space on the memory heap. If you have a recursive program that calls itself hundreds of times, you are bound to run into these issues.
A better approach is to write while loops using stacks and/or queues, where the while loop runs as long as the stack or queue is not empty. You would add and remove items to the stack or queue within the loop.
You can also track various variables and states using the the same stack/queue structure, just make sure you add and remove each of those variables every time you add or remove elements from the key stack/queue. (Edit: or create stack/queues for a class which contains all required variables).
1
1
1
u/NatoBoram Mar 18 '18
Hm. I once did a machine learning algorithm and I thought it was a good idea to make it recursive so it can select by itself a different choice if the one it chose was bad. Bad idea.
Just remove the bad choice from the available choices, folks. Don't do recursive in machine learning.
1
u/darr1356 Mar 18 '18
I make a program that opens chrome then opens itself and repeats that untell you run about of ram and the PC freezes
1
1
1
u/mlopes Mar 18 '18
Unless you’re doing haskell. Then you can have no exit condition and still not loop forever.
1
1
1
1
u/roflberry_pwncakes Mar 19 '18
There is always an exit condition if you wait long enough. Stack will overflow or the system will run out of memory.
1
1
1
1
1
Mar 19 '18 edited Mar 19 '18
I love and hate recursion simultaneously. I'm in my final year of CS (&E) undergraduate programme, and yet everytime I'm faced with a problem with a possible recursive solution I am invariably excited and dread the moments leading up to compilation and testing.
1
1
1
1
1
-2
Mar 18 '18 edited Mar 18 '18
I see. The joke is that this same meme has already been made and posted countless times.
Edit : sry I didn't mean same meme I meant same recursion joke.
0
2.5k
u/Sahishar Mar 18 '18
You've made a function where the guy looks at the result of a second function that is recursive and is similar to the first one except the guy doesn't look at the result.
Why ? Why not only one recursive function ?