this post was submitted on 08 Jul 2023
136 points (93.0% liked)
Programmer Humor
19589 readers
589 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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
One of my guilty pleasures is to rewrite trivial functions to be statements free.
Since I'd be too self-conscious to put those in a PR, I keep those mostly to myself.
For example, here's an XPath wrapper:
Which you can use as
$$$("//*[contains(@class, 'post-')]//*[text()[contains(.,'fedilink')]]/../../..")
to get an array of matching nodes.If I was paid to write this, it'd probably look like this instead:
Seriously boring stuff.
Anyway, since var/let/const are statements, I have no choice but to use optional parameters instead, and since loops are statements as well, recursion saves the day.
Would my quality of life improve if the lambda body could be written as
=> if n then a.push(n), $$$(q,d,x,a) else a
? Obviously, yes.Reminds me when my I did all my homework using list comprehension, ternary operations, and lambda expressions because it was boring. Here's an example
you monster