840
if else if else if else (programming.dev)
top 22 comments
sorted by: hot top controversial new old
[-] Nobug404@geddit.social 41 points 1 year ago
[-] glibg10b@lemmy.ml 29 points 1 year ago

You could've used an actual switch but you chose a USB hub instead

[-] MJBrune@beehaw.org 9 points 1 year ago* (last edited 1 year ago)

You can see the break in the while true, the black switch on the extender.

[-] darcy@sh.itjust.works 8 points 1 year ago

now do function and return

[-] lemmyng@beehaw.org 8 points 1 year ago

I think the foreach one should have been recursion.

[-] DeriHunter@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

Nope recursion would be a bigger cable connected to same cable only smaller, connected to the same cable only smaller, etc..

If this is how your recursion looks like you have a problem and you need to rethink your recursion step and and stop condition :)

[-] MagicShel@programming.dev 3 points 1 year ago

I disagree. Recursion is the same thing over and over again until the exit condition. Nothing is getting smaller except the remaining entries.

[-] kogasa@programming.dev 3 points 1 year ago

That's just "recurrence." The same as a "while" loop. Recursion is specifically when a procedure invokes itself.

[-] MagicShel@programming.dev 2 points 1 year ago

Fair enough. Point is nothing is getting smaller except the call stack.

[-] kogasa@programming.dev 4 points 1 year ago

The thing that's getting smaller is the "complexity" or "distance from the trivial case" of the function invocation. This is an informal notion though.

[-] DeriHunter@lemmy.world 1 points 1 year ago

Of course it does, I suggest you go read about recursion. Here's a link: https://www.cs.odu.edu/~toida/nerzic/content/recursive_alg/rec_alg.html

Good luck

[-] kogasa@programming.dev 2 points 1 year ago* (last edited 1 year ago)

There's no formal reason why the input to a recursive function must be a "smaller" or "simpler" version of itself, that's just a way of explaining it intuitively/informally. You need to reduce the "complexity" (meant informally as 'deviation from a trivial case') at every step (only) if you want to the algorithm to actually finish.

[-] MagicShel@programming.dev 0 points 1 year ago

I've been writing code for 35 years and professionally for 25. I'm plenty familiar with it.

[-] DeriHunter@lemmy.world 1 points 1 year ago

And still you get it wrong. I just linked you an academic article about it, fml. Never got people who are to proud to admit they are wrong.

[-] jlar@lemmy.world 2 points 1 year ago

What the flip did you just freaking say about my code, you little script kiddie? I'll have you know I've been writing code for 35 years and I've used recursion on several occasions, and I have over 300 confirmed successful deployments. I am trained in twelve different programming languages and I'm the top coder in the entire Stack Overflow leaderboard. You are nothing to me but just another code review. I will debug you the flip out with precision the likes of which has never been seen before on this GitHub, mark my freaking words. You think you can get away with saying that crap to me over the Internet? Think again, scripter. As we speak I am contacting my secret network of tech support across the globe and your IP is being traced right now so you better prepare for the DDoS, maggot. The storm that wipes out the pathetic little thing you call your Python script. You're freaking terminated, kid. I can be anywhere, anytime, and I can refactor your code in over seven hundred ways, and that's just with my bare hands. Not only am I extensively trained in machine learning, but I have access to the entire arsenal of Google Cloud Services and I will use it to its full extent to wipe your miserable code off the face of the repository, you little wannabe. If only you could have known what unholy retribution your little 'clever' comment was about to bring down upon you, maybe you would have held your tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn rookie. I will rain code all over you and you will drown in it. You're freaking done, kiddo.

[-] MagicShel@programming.dev 1 points 1 year ago

Point is I know how it works. Maybe you want to argue the analogy, but that doesn't mean I don't understand recursion. I've used it on several occasions.

[-] twotenth@lemmy.ml 2 points 1 year ago

Need one for loop unrolled

[-] sagrotan@lemmy.world 1 points 1 year ago

TIL my life is a logic trap...

[-] Nobug404@geddit.social 1 points 1 year ago
[-] drew_belloc@programming.dev 1 points 1 year ago

While true is how i store my usb extension

load more comments
view more: next ›
this post was submitted on 21 Jul 2023
840 points (97.4% liked)

Programmer Humor

19623 readers
1 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS