sindresorhus / Actions

⚙️ Supercharge your shortcuts
https://sindresorhus.com/actions
MIT License
2.58k stars 109 forks source link

Action proposal: Logical operator expressions (AND/OR/XOR/etc.) #114

Open colin273 opened 1 year ago

colin273 commented 1 year ago

Description

This would accept two conditions, configured very much like the conditions used in Shortcuts’ built-in If statements, and return a Boolean indicating whether they are both true (AND), at least one is true (OR), both have opposite values (XOR), or the negations of those operators. The user would be able to select which operator the action uses.

For example:

Without this action, I would implement the above example like this:

This works for two conditions, but any more and the cascade of If statements becomes much larger. It would be great to be able to represent these in a concise way.

A series of these actions could also be used to represent even more conditions at once. (e.g. (a && b) || (c ^ d) would take three of these actions, since there are AND, XOR, and OR operations in that statement)

sindresorhus commented 1 year ago

Any suggestions how the action(s) should look like?


What I'm thinking:

A single action called Is True.

It would let you pick these modes:

Usage:

(All true): (Variable 1) (Variable 2) (Variable 3)

I'm open to other ideas. Other name ideas too.

jsiegenthaler commented 1 year ago

Namen them the same as Excel:And(var1,var2,var3,…)Max say 10 variables. Var1 and var2 are mandatory, all others optional. Same for Or() and Xor()Regards JochenSent from my iPhoneOn 27 Apr 2023, at 07:53, Sindre Sorhus @.***> wrote: Any suggestions how the action(s) should look like?

What I'm thinking: A single action called Is True. It would let you pick these modes:

All true (and) All false (and) Any true (or) Any false (or) XOR (this one would only accept two variables)

Usage: (All true): (Variable 1) (Variable 2) (Variable 3)

I'm open to other ideas. Other name ideas too.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

colin273 commented 1 year ago

Any suggestions how the action(s) should look like?

What I'm thinking:

A single action called Is True.

It would let you pick these modes:

  • All true (and)
  • All false (and)
  • Any true (or)
  • Any false (or)
  • XOR (this one would only accept two variables)

Usage:

(All true): (Variable 1) (Variable 2) (Variable 3)

I'm open to other ideas. Other name ideas too.

Sounds reasonable to me. This naming scheme would a good way to present these concepts to users, consistent with terminology used in Apple's filter actions, without overwhelming them with Boolean logic jargon.

The action name "is true" is okay. It's not the first thing I would think of when searching for it in the app, but something like "logic gates" could be a bit too geeky for most people. That's what keywords are for, I suppose.

I'm not sure what to name XOR without calling it exclusive or. "Only one is true"? XNOR would probably be "Both true/false" in that case.

As a side note, "all false" would be NOR and "any false" would be NAND. Not sure if these gate names would be included in the action description.