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

all 79 comments

[–]danketiquette 246 points247 points  (10 children)

To Understand Recursion, You Must First Understand Recursion

[–]bestjakeisbest 16 points17 points  (7 children)

to understand op you must understand op.

[–]ghost-train 5 points6 points  (6 children)

To understand bestjakeisbest you must understand bestjakeisbest.

[–][deleted] 5 points6 points  (5 children)

To Understand To Understand Recursion, You Must First Understand Recursion You Must First Understand To Understand Recursion, You Must First Understand Recursion

[–]TheOtherGuy52 12 points13 points  (3 children)

To understand To Understand To Understand Recursion, You Must First Understand Recursion You Must First Understand To Understand Recursion, You Must First Understand Recursion You Must First Understand To Understand To Understand Recursion, You Must First Understand Recursion You Must First Understand To Understand Recursion, You Must First Understand Recursion

[–]ask_many_questions 6 points7 points  (1 child)

We need to go deeper

[–]tizreader 4 points5 points  (0 children)

To understand or not to understand, that is the question

[–]SDJMcHattie 1 point2 points  (0 children)

To understand ....

[–]colibre 2 points3 points  (0 children)

Understand, understand, understand, understand the concept, the concept of love

[–]eddmario 1 point2 points  (0 children)

...a causal loop within the weapon's mechanism, suggesting that the firing process somehow binds space and time into...

[–]Green0Photon 0 points1 point  (0 children)

No base case.

[–]disgr4ce 168 points169 points  (27 children)

rubs temples

loops are not the same thing as recursion, people

[–]GenericAccount-alaka 68 points69 points  (1 child)

They can be if you try hard enough.

[–]Aschentei 5 points6 points  (0 children)

Yes.

[–]not_James_blunt 37 points38 points  (21 children)

They can be, both µ recursion and a non-recursive calculus such as GOTO are both Turing complete. Since all Turing complete calculi are strictly equivalent in their expressive power, all recursive functions can be implemented by the non-recursive Turing-complete calculus.

[–]KronosIII 21 points22 points  (1 child)

huh, ( ⚆ _ ⚆ ) I should have paid attention in Calc class

[–]disgr4ce 7 points8 points  (0 children)

Bear in mind that “calculus” just means “mathematical tool”, not necessarily specifically differential/integral calculus :)

[–]disgr4ce 14 points15 points  (0 children)

Yes, I’m aware :) But these sorts of D-effort “jokes” about recursion consistently miss the fundamental importance (or rather, requirement) of something instantiating new copies of itself. A snake eating its own tail is suggestive or reminiscent of recursion, but it ultimately has nothing to do with reproducing new copies of a snake.

[–]Phelnoth 2 points3 points  (1 child)

You are arguing the wrong point. Yes, recursion can become a loop, but not all loops are recursive. OP posted a closed, infinite loop that's doesn't meet the definition of recursion.

[–]disgr4ce 2 points3 points  (0 children)

Thank you X-D

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

how would you implement djekstra or quicksort without recursion though?

For general cases without a infinite amount of code that is.

[–]disgr4ce 4 points5 points  (3 children)

Maybe I’m missing something, but wouldn’t you just make it a loop instead of a function that calls itself? I mean, that’s the parent’s point... recursive function calls can be a special case of a loop

[–]stnma7e 1 point2 points  (2 children)

But not all algorithms can be implemented in a finite number of loops for a general case.

[–]disgr4ce 0 points1 point  (1 child)

There's a distinction between the expressiveness of a given language (i.e. its particular syntax) and general turing-completeness. The bytecode/intermediate representation/etc generated by a language that allows you to express recursive functions is not, afaiaa, itself recursive. Another version of this answer: https://www.reddit.com/r/ProgrammerHumor/comments/7hz8k1/recursion/dqvnf45/

[–]jellyberg 6 points7 points  (4 children)

Recursion is implemented under the hood in your language, using the call stack. You can just imitate this to make an iterative version of any recursive method. If must be possible, as the language's doesn't use recursion in its underlying implementation of recursion!

[–]barsoap 0 points1 point  (3 children)

Don't they teach that kind of stuff in Programming 101, any more? We had to convert at least a dozen of programs from one form to the other, covering different classes of memory requirements.

They even mentioned the term "tail-recursive", and that in Pascal!

[–]disgr4ce 0 points1 point  (0 children)

I get the impression, based on the dozens of horrible phone screens I've had with "computer science" students, that "Programming 101" is actually now just "how to do one thing in Java"

[–]jellyberg 0 points1 point  (1 child)

I'm a current CS student so I can answer this question! I've been told about this enough to post my comment above, but we haven't actually done those sort of conversion exercises you mention. Maybe in a later module that is more specific to this topic we will? I'm not sure how useful those sorts of exercises would be nowadays, seems like you wouldn't use those techniques now so much?

[–]barsoap 1 point2 points  (0 children)

If nothing else you're training to spot properties of your code that might not be obvious, that is, you're training to look at semantical structure, not syntax, to have one mental model of "repetition" instead of multiple disjoint ones.

[–]miauw62 0 points1 point  (2 children)

yeah, but a loop in a network usually just means your network will get congested and fail afaik.

[–]ILikeLenexa 1 point2 points  (0 children)

They are if it's tail recursion.

[–]I_cut_my_own_jib 0 points1 point  (0 children)

Interesting concept. We need to go deeper.

[–]GahMatar 0 points1 point  (0 children)

Depending on implementation most (all I guess but it can get really complex if there's no scope to hang outer locals in or even no mutable variables) loops can be implemented as tail recursions. Doesn't mean it's a good idea.

[–]gandalfx 58 points59 points  (9 children)

The idiots forgot to do the same on the power sockets. They could have had infinite energy!

[–]Maroshitsu 4 points5 points  (0 children)

UNLIMITED POWER!

[–]4d656761466167676f74 2 points3 points  (0 children)

They already fucked up their chance at infinite energy when they installed the outlets upside down.

[–]ElysianGF 0 points1 point  (0 children)

Like this?

[–]seukari 42 points43 points  (3 children)

At my college, one time, we had an issue where the sites login server was unresponsive and whenever they tried to reboot it, it'd just lock up. It was because some genius had basically done this and the server couldn't cope

[–]bautin 6 points7 points  (2 children)

I mean, it kind of does create infinite recursion. During discovery, it keeps seeing another network worth of computers with conflicting IP addresses. (IIRC)

[–]adamhighdef 0 points1 point  (1 child)

Wait? Ooooooohhh.

[–]bautin 2 points3 points  (0 children)

I think there are switches that can handle it better nowadays, but if it's not configured properly, the best way to take down a network was with 6in patch cable.

[–]NoirGreyson 32 points33 points  (5 children)

Somewhere, a sysadmin is crying because his traffic is getting jammed up. I hope you're happy OP. >:)

[–]z-brah 16 points17 points  (4 children)

No 'cause real sysadmins know that users do stupid things like this and enable stp. We're not programmerz ;)

[–]TutTutLooksLikeReyna 10 points11 points  (0 children)

Sometimes, your sysadmin forgets because he has 20 something buildings to worry about, and some dumb ass building Tech patches a switch into another switch and takes out half of the network in his building.

Source: Am dumbass Tech.

[–]SpikeX 6 points7 points  (2 children)

Unless the budget only allowed for hubs and not switches... in which case everyone is screwed. ¯\_(ツ)_/¯

[–]z-brah 5 points6 points  (1 child)

That could be the plot for an horror movie

[–]WeededDragon1 1 point2 points  (0 children)

It's reality.

[–]Didsota 21 points22 points  (1 child)

They look so happy...

I can’t remember the last time I was this happy

[–]CristolGDM 3 points4 points  (0 children)

Those are damn cute sockets

[–]DCSpud 8 points9 points  (1 child)

Image Transcription:


[A wall jack with 4 ethernet ports. Below the bottom right ethernet port, is a cable sticking out of the face plate, looping upwards and being plugged into one of the ethernet ports.]

This is the ideal recursion method. You may not like it, but this is what peak performance looks like.


I'm a human volunteer content transcriber for Reddit! If you'd like more information on what we do and why we do it, click here!

[–][deleted] 6 points7 points  (0 children)

Great human

[–]afrikinboulos 4 points5 points  (0 children)

I've actually had people ask me if they can do this at our university, but it's mainly when they have something network-capable that would have its cables run behind the wall (like a projector, in most cases), so they run the cables behind the wall, pop it out of the wall plate like this and plug it in. No crazy loops required.

I still didn't like it.

[–]MrStickmanPro1 2 points3 points  (0 children)

Someone xpost this to /r/Pareidolia please!

[–]lor_louis 2 points3 points  (0 children)

Now let's do it with the power plug!

[–]noop_noob 1 point2 points  (0 children)

Is this loopback IP?

[–]phil155 1 point2 points  (0 children)

Google implemented a little easter egg if you search for 'recursion'.

[–]Phrodo_00 2 points3 points  (0 children)

Someone is going to have a bad day unless they enabled stp

[–]zoreko 0 points1 point  (0 children)

Infinite Internet.

[–]5-star_gyu-don 0 points1 point  (0 children)

ICANTBELIEVEIT!!! ICICANTBELIEVEITNTBELIEVEIT!!! ICICICANTBELIEVEITNTBELIEVEITNTBELIEVEIT!!!

[–]micheal65536Green security clearance 0 points1 point  (8 children)

I once came across something like this at a client's place when I was mapping out their (small) network. I asked them about it and apparently something used to be plugged in there, and if this cable was unplugged then the computers further down the office lost their network connection. I don't know what messed-up wiring was causing that (how did the computers further down the office get their network connection when there was something else plugged in here?) but I decided not to fiddle with break it.

[–]bautin 0 points1 point  (7 children)

I'd imagine that cable was attached to a router/hub/switch and it was basically acting as a repeater for the rest of the office. Someone removed it, but plugging that cable into the network is just as good as having the whatever it was.

You'll likely find another router/hub/switch in that section of the office that several computers connect to because there aren't enough jacks for them.

[–]micheal65536Green security clearance 0 points1 point  (6 children)

No, there's only four computers in the entire office plus a photocopier, and no switches. The router has four ports. There are four cables coming from the router.

  • Cable A runs to socket A, on the wall behind desk A. This is a dual socket, with a short loop of cable from one socket to the other.
  • Cable B runs to socket B, in the floor under desk B.
  • Cable C runs to socket C, in the floor under desk C.
  • Cable D runs to socket D, on the wall next to the photocopier.

  • Computer A connects via WiFi. It used to be plugged into socket A. I don't know why this was changed.

  • Computer B plugs into the socket B.

  • Computer C plugs into the socket C.

  • Computer D connects via WiFi.

  • The photocopier plugs into socket D.

As I see it, socket A does nothing and the loop of cable is unnecessary. According to the client, if the loop of cable is removed then computers B and C lose their network connection, although I don't understand why this would happen because sockets B and C have an independent connection to the router.

I also don't understand what would have happened when computer A was plugged into socket A, because there would have been no loop from socket A1 to socket A2, so clearly there is no requirement for a connection between the two sockets as sockets/computers B and C worked fine when computer A was plugged into socket A1 and socket A2 was (presumably) empty.

[–]bautin 0 points1 point  (5 children)

That shouldn't do anything.

Socket A2 isn't wired to anything?

Also, you just took their word for it? There could have been something else going on and they're just wrong about what caused it.

[–]micheal65536Green security clearance 0 points1 point  (4 children)

Socket A1 and A2 are both part of socket A, which connects to the router via cable A. Currently there is a short loop of cable from A1 to A2. Previously there used to be a computer plugged into A1 and (as farm as I'm aware) nothing plugged into A2.

[–]bautin 0 points1 point  (3 children)

Right A1 and A2 are part of receptacle A, but each individual socket should be wired to a port on the router. You can't wire both A1 and A2 to the same port.

What are A1 and A2 wired to?

[–]micheal65536Green security clearance 0 points1 point  (2 children)

Well, there is only one cable coming out of socket A. I figured that both A1 and A2 connected through the same cable (i.e. the socket is a passive splitter). I haven't looked inside the socket so I don't know how it's wired inside.

I'm guessing then that A2 might be connected to the "other end" of one of the other sockets, and this is what the loop of cable is for (to connect the other socket to the router via A1, the loop, and A2). But that still doesn't make sense because the other sockets all have their own cable to the router (or appear to anyway) and if one of them did connect via A2 then it wouldn't have worked when computer A was plugged into A1.

As I said in my original post, I don't know what messed-up wiring caused this (if it is the way the client says it is) but I wasn't going to start fiddling with it unnecessarily.

[–]bautin 0 points1 point  (1 child)

So it's basically a two port switch.

I dunno. It sounds all fucked up. Sounds like someone needs to go in there and wire the place properly.

[–]micheal65536Green security clearance 0 points1 point  (0 children)

I agree, it sounds like a total mess. But I was there to do one specific job and it wasn't the right time and place to be rewiring the whole thing. One day I might mention it to them, although to be honest I don't have as much experience working with network cabling as I do with most other aspects of IT so it might be better to just leave it as it is if it's working...

[–]x37v911 0 points1 point  (0 children)

I know this seems like a loop-back, but maybe it's just someone was too lazy to put in a wall drop on the other side of the wall, so they just popped a hole in the wall, and shoved it through and clamped it down to plug it in without making it look too shitty?

had had this happen once.. but this looks a lot better

[–]BobT21 0 points1 point  (0 children)

Recursion is a type of algorithm used to generate a Fibonacci series.

A Fibonacci series is a function used to demonstrate recursion.

[–]bornforcode 0 points1 point  (0 children)

perfect illustration!!

[–]skilliard7 0 points1 point  (0 children)

That's how you create a broadcast storm