SKBLu
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
codeinabox@programming.dev to Programming@programming.devEnglish · 20 days ago

Negating compound boolean expressions (De Morgan's Laws)

pawelgrzybek.com

external-link
message-square
3
link
fedilink
21
external-link

Negating compound boolean expressions (De Morgan's Laws)

pawelgrzybek.com

codeinabox@programming.dev to Programming@programming.devEnglish · 20 days ago
message-square
3
link
fedilink
Negating compound boolean expressions (De Morgan's Laws) | pawelgrzybek.com
pawelgrzybek.com
external-link
A pair programming session made me explore De Morgan’s Laws. Here is a quick example and the essence of the rules defined by Augustus De Morgan.
alert-triangle
You must log in or # to comment.
  • MagicShel@lemmy.zip
    link
    fedilink
    English
    arrow-up
    5
    ·
    20 days ago

    Boolean Algebra is one of the few things I learned in electronics that I still apply in programming all the time.

  • thingsiplay@beehaw.org
    link
    fedilink
    arrow-up
    3
    ·
    20 days ago

    !(r.SendNow || r.DryRun) requires you to read the entire statement and then negate the result. While !r.SendNow && !r.DryRun each part of the statement stands on its own and is negated for themselves. That is how I read. I like the Ai suggestion more, because that is how I would write it myself. What I like about it is, that the negation of is right there with the variable. It gets more important, the more you divide sub-expressions in multiple lines.

  • HaraldvonBlauzahn@feddit.org
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    11 days ago

    The funny thing is that not C or Rust as languages “close to the hardware” have more specific bitwise operations - but Common Lisp has:

    https://www.lispworks.com/documentation/HyperSpec/Body/f_logand.htm

    https://www.lispworks.com/documentation/HyperSpec/Body/f_logcou.htm

    https://www.lispworks.com/documentation/HyperSpec/Body/f_boole.htm#boole

    (Though Rust has at least popcnt() and count_ones(), which are immensely useful e.g. when processing small sets.)

Programming@programming.dev

programming@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programming@programming.dev

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 390 users / day
  • 602 users / week
  • 2.3K users / month
  • 7.33K users / 6 months
  • 1 local subscriber
  • 23.7K subscribers
  • 1.55K Posts
  • 14.6K Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • MaungaHikoi@lemmy.nz
  • UlrikHD@programming.dev
  • BE: 0.19.13
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org