4

In programming what do you call a choice that is not Boolean?

ie. a Boolean condition is a true/false, either-or possibility.

What do you call a condition with one or more possibilities? And, is there any difference if the condition is zero or more versus one or more?

Thanks!

--EDIT--

To add some clarity:

Specifically I'm having a hard time when describing certain types of algorithms to non-programers. I'm a hobbyist programmer so I lack a lot of the vocabulary that comes with a computer science degree.

If I present a user with an "either-or" choice, I find the users understand what I mean if I call this a "boolean" choice, even if it has more than two possibilities.

For example: "Pick a color: red, yellow, green, or blue."

If I have something that's a "one or more" choice I don't know what to call that.

For example: "Select any colors that you like: red, yellow, green, blue."

How do you (knowledgeable programmers) refer to these kinds of choices when you talk about them?

-- SECOND EDIT --

As was pointed out in the comments I shouldn't even be saying "Boolean", I should be saying "Binary." That makes perfect sense...

So, is there such a thing as "polynary"?

10
  • 2
    an enum that's selected with a switch? dotnetperls.com/switch-enum – patrick Jul 19 '11 at 21:53
  • 3
    TRUE, FALSE, FILE_NOT_FOUND - theDailyWTF logic! – user7519 Jul 19 '11 at 22:04
  • 2
    "Opposite" is such a misleading word in this case... – Mark Canlas Jul 19 '11 at 22:25
  • 2
    Boolean is not an "Either/or" it is True/False. BINARY is a choice between two options. – JohnFx Jul 19 '11 at 23:38
  • 3
    This question appears to be off-topic because it is a "name that thing" question. "Name that thing" are bad questions for the same reasons that "identify this obscure TV show, film or book by its characters or story" are bad questions: you can't Google them, they aren't practical in any way, they don't help anyone else, and allowing them opens the door for the asking of other types of marginal questions. See blog.stackoverflow.com/2012/02/lets-play-the-guessing-game – gnat Oct 26 '13 at 22:25
1

Specifically I'm having a hard time when describing certain types of algorithms to non-programmers.

I'm not sure if computer science terms will help you with this : )

For example: "Pick a color: red, yellow, green, or blue."

The layman would call it a "multiple-choice question." Like those scangrade questions where you fill in the answer with a Number 2 pencil.

For example: "Select any colors that you like: red, yellow, green, blue."

I would call that "multiple-select question." Choice implies a single decision, but selection generally allows for including multiple objects.

2
4

When you have the possibility to refer to one or more values, you could call this options.

An implementation of this in e.g. C# is using a flags enum.

[Flags]
enum SelectedColor
{
    None, Red, Yellow, Green, Blue
}

SelectedColor colors = SelectedColor.Red | SelectedColor.Green;

This uses an underlying value type where every bit of the value represents one possible option. E.g. when the underlying value type is an Int32 you can specify 32 separate possible options.

0000 = None
0001 = Red
0010 = Yellow
0100 = Green
...
3

It's usually called a "switch" - like this one in C#

It lets you choose between many possibilities. You could even write one that had just two choices like an if statement.

int caseSwitch = 1;
switch (caseSwitch)
{
    case 1:
        Console.WriteLine("Case 1");
        break;
    case 2:
        Console.WriteLine("Case 2");
        break;
    default:
        Console.WriteLine("Default case");
        break;
}
2
  • Switch is good -- but doesn't that still usually mean you pick one of the possible cases rather than possibly many of the cases? What do you call the logic where many possibilities may happen, not necessarily one or the other? – Andrew Jul 19 '11 at 21:57
  • 1
    @Andrew - Ah. You can code a switch so that many values execute the same code, but there has to be a single value executed at any one time. Perhaps you need to clarify your question. – ChrisF Jul 19 '11 at 21:59
3

If I have something that's a "one or more" choice I don't know what to call that.

In the content management system we have where I work this would be called a "Pick list" to select the values where if one wanted to see the raw value it is a pipe-delimited list of a GUIDs. "Sets" would be the Mathematical construct you seem to be using here as one could do a check of MyColors.Count > 0 for a Boolean check on if there is are some items in the MyColors variable. There is also methods like Contains to check if a set, often called a collection or list which could be implemented using arrays or linked lists, has a specific member or not in some languages.

Hopefully that is what you mean. Short-circuit evaluation comes to mind as an area where one can have an "I don't care" situation in some cases.

0
2

By definition, a boolean can only be either true or false, 1 or 0. There's nothing confusing about that. In terms of explaining to a user your situation: "Pick a color: red, yellow, green, or blue." It is simply a single choice from a set of colours.

Contrast this with: "Select any colors that you like: red, yellow, green, blue." This is simply said to be multiple choices from a set of colours.

Neither of these situations are boolean equivalent options. You can argue that the decision to make a choice is, in and of itself, a boolean operation: you either choose a value, or you don't.

I'm not entirely sure if this is what you're trying to get at, but I suppose that's how I see booleans.

1
  • Yeah that makes sense. I think where Boolean comes from is "you either picked red or you didn't," whereas I'm not sure how to describe the logic of "you could have picked zero, one, or many options". – Andrew Jul 19 '11 at 23:20
1

Are you perhaps referring to a Bit Field? It's generally represented as an Enumeration with fixed binary position values, which can be used to specify 0...n combinations of values.

1

When talking of what an operation returns, I'd distinguish between here between scalar and set-wise return types.

When talking instead of what an operation demands—that is, its parameters—I'd characterize its arity as monadic (exactly one), dyadic (exactly two), or polyadic (any nonnegative number, as is customary with a count). Alternatly, one could use unary, binary, and n-ary, respectively.

0

In Java you would have a Set of enum values. Under the bonnet it uses a bit map.

enum Colour { Red, Blue, Yellow, Green }

Set<Colour> colours = EnumSet.of(Colour.Blue, Colour.Green);

colours.add(Colours.Red);
if (colours.contains(Colour.Yellow)) {
    colours.remove(Colour.Blue);
}
System.out.println(colours);

prints

[Red, Blue, Green]
0

So, is there such a thing as "polynary"?

I would use the word "discrete", as in "a set of discrete options."

Not the answer you're looking for? Browse other questions tagged or ask your own question.