r/shittyprogramming • • Dec 05 '14

Recursion 101

Post image
316 Upvotes

73 comments sorted by

View all comments

6

u/seiyria Dec 05 '14

What is recursion?

35

u/stevethecow Dec 05 '14

Recursion is recursion

9

u/drEckelburg Dec 05 '14

Recursion is recursion is recursion

2

u/Schadenfreude775 Dec 05 '14

6

u/[deleted] Dec 05 '14

Did you mean: recursion

27

u/bloodsh0t5 Dec 05 '14

To understand recursion, you must first understand recursion.

18

u/brewspoon Dec 05 '14

Always include the base case: you understand recursion.

3

u/detroitmatt Dec 08 '14 edited Dec 08 '14

To learn recursion: If you understand recursion, stop. Otherwise, learn recursion.

9

u/psluredd Dec 05 '14

4

u/PotentPortentPorter Dec 05 '14

How did you link to your own post without an edit? O_o

8

u/[deleted] Dec 05 '14

You can edit your post up to 3 minutes after posting and it won't display as edited.

1

u/c22mcdon Dec 05 '14

What is recursion what is recursion?

0

u/OrionBlastar Dec 05 '14

When a function calls itself.

Which is good for calculating Fibonacci numbers or Ackerman numbers, but you have to have a variable or variables that decrease over time to prevent infinite recursion that results in a stack overflow.

Here recursion is used to computer Ackermann numbers in C++:

https://github.com/orionblastar/ackermann0/blob/master/ackermann0.cpp

7

u/seiyria Dec 05 '14

shittyprogramming

taking me seriously

this sub should be called badprogramming, no one can ever act "shitty" :(

-3

u/OrionBlastar Dec 05 '14

Shitty programming is like this:

int worddata; printf(worddata);

Stuff where you forget to initialize a variable and it pulls data from a random location in memory where the variable is stored. Yet the compiler does not notice it, compiles the shitty code, and it prints some random number each time it runs.

Shitty programming is just not paying attention to what you are doing, not taking the time to look it over and debug. Not following directions and getting things confused.

A function that just calls itself with no way to terminate the recursion is just another example of an infinite loop.

Shitty programmers always shoot themselves in the foot and then blame someone else for their mistakes.

I used to work with a lot, had masters and PHDs in computer science and still were shitty programmers that I always had to debug their code to fix problems like that.

5

u/seiyria Dec 05 '14

Have you ever been on a shitty network subreddit? /r/shittyaskscience maybe? pls

-6

u/OrionBlastar Dec 05 '14

Nope it looks like circlejerk.

For a really shitty network subreddit try /r/kuro5hit it is run by Trolls from Kuro5hin when /r/kuro5hin locked them out. Kuro5hin is a troll website based on Scoop that started out as a Slashdot clone and ended up a Troll Paradise.

7

u/seiyria Dec 05 '14

Ok, then you don't get how the shitty network operates. Sorry, but the jokes (and most of this subreddit) will probably go over your head. Carry on.

-1

u/OrionBlastar Dec 05 '14

Bad code is not funny, it causes all kinds of problems.

→ More replies (1)

0

u/[deleted] Dec 05 '14

[deleted]

1

u/OrionBlastar Dec 05 '14

I didn't get that from the sidebar. Replies go directly to my inbox. So I don't see the sidebar, much less be able to read it.

This is one of my first times posting here, why be shitty on purpose when you can do better?

0

u/[deleted] Dec 05 '14

[deleted]

0

u/OrionBlastar Dec 05 '14

I have schizoaffective disorder, I don't always get jokes. It is something we share with autism.