switch statements

switch statements require you to exhaustively consider all relevant or possible inputs (if you don’t rely on default).

Interestingly, the notion that switch statements can require a default is reflective of the truth to the idea that when the stakes get high, we all fall back to our default level of training or function. This has global applications to our functionality and, by extension, the inputs (things,people/their methods,contexts) in our lives as well

6 points
*

using regex to find the absolute value of a number:
$number =~ s/-//;

using regex to check if a number is odd:
print “odd!\n” if (($number / 2) =~ /\./)

…and generally abusing regex for weird stuff it wasn’t intended for, because the regex engine is surprisingly efficient.

🌼 Just PERLy Things! 🌼

permalink
report
reply
3 points

That is beyond obscure haha! Love it

permalink
report
parent
reply
8 points

Absolute value: if less than zero multiply by -1

Is Odd: if modulo 2 is 1

At most both of those are a 3-4 (x86) CPU instructions. There’s no way any regex engine is going to be remotely equivalent if we’re talking about efficiency.

I always had a suspicion you perl guys were crazy

permalink
report
parent
reply
1 point

Absolute value: root of value^2

permalink
report
parent
reply
17 points

Do the important shit first.

I guess this may be more of a project management thing, but trying to figure out what the most important part of a task is, and getting that done first.

If I’m cleaning the bathroom, I do the sink, because if I have to stop, that’s typically the grossest part.

When I’m doing my taxes, I do the stupid parts that I can’t afford to get wrong first.

When I’m packing for a trip, I get the stuff I need day-to-day sorted out and in my carry-on.

I don’t think these are great examples, but they mean something to me.

permalink
report
reply

Please teach us how to have the sink be the grossest part of the bathroom.

permalink
report
parent
reply
1 point

It’s installed on a slight angle, so water pools in the soap holders and around the back of the faucet. If we don’t keep it dry, pools fill with gunge.

permalink
report
parent
reply
2 points

You mean like Soundgarden?

permalink
report
parent
reply
4 points

so the toilet isn’t #1? is it #2?

permalink
report
parent
reply
1 point
*
Deleted by creator
permalink
report
parent
reply
2 points

Fun fact, in a pinch the sink can be used as a urinal.

permalink
report
parent
reply
9 points

Often when I’m working on some code, all my errors are because of something much different than what the error message is telling me. I’ve learned that often, most problems have a different cause and better solution.

permalink
report
reply

Especially in relationship conversations.

permalink
report
parent
reply
8 points

I’m good at breaking down problems into small chunks and not getting overwhelmed by a big project. Do I have the motivation to finish these tasks? That’s a different question.

permalink
report
reply
4 points
*

Appreciating possible failures (pessimism, some call it) and being methodical, even if it’s tediously methodical.

Interestingly, the notion that switch statements can require a default is reflective of the truth to the idea that when the stakes get high, we all fall back to our default level of training or function. This has global applications to our functionality and, by extension, the inputs (things,people/their methods,contexts) in our lives as well

wat

permalink
report
reply
1 point

Life/abillity to cope = switch statement

Have an effective default response programmed in you cuz sometimes shit be crazy

permalink
report
parent
reply
1 point

pessimism

Could this be harnessed for inverse thinking?

permalink
report
parent
reply

Ask Lemmy

!asklemmy@lemmy.world

Create post

A Fediverse community for open-ended, thought provoking questions


Rules: (interactive)


1) Be nice and; have fun

Doxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can’t say something nice, don’t say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them


2) All posts must end with a '?'

This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?


3) No spam

Please do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.


4) NSFW is okay, within reason

Just remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either !asklemmyafterdark@lemmy.world or !asklemmynsfw@lemmynsfw.com. NSFW comments should be restricted to posts tagged [NSFW].


5) This is not a support community.

It is not a place for ‘how do I?’, type questions. If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email info@lemmy.world. For other questions check our partnered communities list, or use the search function.


6) No US Politics.

Please don’t post about current US Politics. If you need to do this, try !politicaldiscussion@lemmy.world or !askusa@discuss.online


Reminder: The terms of service apply here too.

Partnered Communities:

Tech Support

No Stupid Questions

You Should Know

Reddit

Jokes

Ask Ouija


Logo design credit goes to: tubbadu


Community stats

  • 11K

    Monthly active users

  • 4.7K

    Posts

  • 252K

    Comments