If it’s a good library, just the getting started code snippet, but I just meant focus on making good code, and don’t bother deciphering s$&@, no need to scavenge the garbage bin
Delete the bad code, just write the whole function new. Provided the function ever had a reasonable name/documentation/interface description so you know what it was supposed to do at all.
Rewrite an indecipherable function based on the name/description? This assumes there aren’t some edge cases being accounted for. In the projects I work in this would be a recipe for exponential bug growth.
Using bad code can lead to a lot of frustration and bug discovery. It can always be a time sync, on the other hand, I know the code I produce is clean.
After being bit, if I am tasked to work on something, that means it’s probably broken, otherwise I wouldn’t be working on existing code, only adding code, so that’s the first red flag. Secondly, I run the program as a test, and if it doesn’t run, that means it’s broken, it’s much less time consuming to ditch modules and write clean, than try to follow in the footsteps of potential morons. It’s not just about bugs but also bad structures, data flows and software design.
In the corporate world, you are never tasked to rework working code, managers don’t like that, they love legacy code and the status quo. If you are there it’s to fix a problem
There are many reasons to revisit old code other than to fix a bug. Whether it be implementing new features, Re-implementing an old component elsewhere, or replacing legacy code that is blocking new improvements.
Yes, in many cases I will be writing it over cleanly, however blindly re-writing just any indecipherable functions I see based on name/description would cause more problems than it solves.
Being able to quickly untangle somebody else's bad code is a very very useful skill that your management won't appreciate. Not being able to quickly untangle somebody else's bad code is something management usually will blame you for.
It's fairly common in my experience for code jockeys to write tangled broken non-commented messes of code and then quickly hop to other teams before their implementation catches up to them.
I have seen bad programmers in my day, but this one guy, is running a scam or something, can’t write a function to save his life, I think outsources what he can’t find exactly by googling, code has more bugs than code, never meets deadlines, and still employed somehow.
It defines a factorial lambda function and then uses it to computes the result of 5!, right? It shouldn’t been more simple to just store the result of 5! inside a constant?
100
u/[deleted] Oct 11 '21
I don't even know what this does
48
u/JackFly26 Oct 11 '21
am i crazy or is this just an example of using the y combinator, it's probably just used to teach lambda calculus/fp
87
u/ososalsosal Oct 11 '21
This is worse than reverse polish notation written as regex
6
u/[deleted] Oct 11 '21
Was this deliberately obfuscated?
9
u/jzia93 Oct 11 '21
I'd probably stick to if else in this situation. Ternary makes this look like code golf
5
u/Pcat0 Oct 11 '21
I feel called out
2
u/ThaCuber Dec 11 '21
hold on how is this even possible, aren't you unable to reuse anonymous functions if you haven't assigned them to a variable?
49
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Oct 11 '21
Image Transcription: Code
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!
23
u/Tvde1 Oct 11 '21
why... combinator
15
u/Knuffya Oct 11 '21
That's a weird resignation letter
8
u/Pangocciolo Oct 11 '21
It's a factorial!
Captain Obvious will return with his unneeded explanations.
12
u/MorrowM_ Oct 11 '21
I was confused until I realized the first function was just
fix.6
u/C_isBetter_Than_Java Oct 11 '21
We need to go deeper. Make each call asynchronous and create its own thread.
6
u/[deleted] Oct 12 '21
I see nothing but average Lisp code.
5
u/[deleted] Oct 11 '21
The worst of FP
9
u/[deleted] Oct 11 '21
It defines a factorial lambda function and then uses it to computes the result of
5!, right? It shouldn’t been more simple to just store the result of 5! inside a constant?4
u/DreamingDitto Oct 11 '21
This is the only time learning lisp has come in handy
3
u/ilikedankmemes3 Oct 12 '21
bool evenOdd(int val){ switch(val){ case 0: return true; case 1: return false; default: return evenOdd(val-2); }
}
3
u/robin_888 Oct 12 '21
This should definitely be on one line.
4
u/Dantharo Oct 11 '21
very readable, u can do this but u dont need to do this lol
2
u/[deleted] Oct 11 '21
I shouldn't feel physical pain looking at code
2
u/[deleted] Oct 11 '21
I don’t see the problem /s
2
u/Sc3m0r Oct 11 '21
My brain just broke. That's it. I'm gonna start studying economics.
2
u/[deleted] Oct 11 '21
This seems like a really good test case for a language actually
2
u/kredditbrown Oct 11 '21
honestly, the best post I've seen in any programming related thread
2
u/itsTyrion Oct 12 '21
What the shit
2
u/[deleted] Oct 12 '21
What the fuck
2
u/dfmaaa1 Oct 12 '21
wth
2
u/trutheality Oct 12 '21
That's some galaxy brain code.
0
u/[deleted] Oct 11 '21
[deleted] — view deleted comment