# What's a good data structure to represent a, b, a and b, a or b? [closed]

I have a function foobar[x_] that can produce 4 types of output

a
b
a or b
a and b


What's a good data structure, or better even, a good built-in function (head) that can represent this? I don't want to use And[] and Or[] as a, b aren't boolean. Is this a silly question?

The intended use of foobar[], or more precisely the expression it evaluates to, is to represent the type of some other expression.

## My idea 1

is to use

foobar[x_] := Which[
<condition for "a" scenario>, {{a}},
<condition for "b" scenario>,, {{b}},
<condition for "a or b" scenario>, {{a}, {b}},
<condition for "a and b" scenario> {{a, b}},
]

-
The choice of data structure will depend on what you intend to do with it. In this case, I see nothing wrong with your idea... if used correctly down the road. Perhaps adding a bit more background and what you intend to do might get you better responses – rm -rf Oct 10 '12 at 17:31
By using Piecewise instead of Which you get a nice TraditionalForm – belisarius Oct 10 '12 at 17:46
The addendum could not have been any more vague :) More seriously, what's missing is the why. Why do you think your construct is insufficient? You probably have a reason for that — is it slow? Is it clumsy to work with? Are you having troubles using this output format?, etc. – rm -rf Oct 10 '12 at 18:02
Another possible choice could be a, b, either[a,b] and both[a,b]. Or oneof[a], oneof[b], oneof[a,b], allof[a,b]. Or {1,{a}}, {1,{b}}, {1,{a,b}}, {2,{a,b}}. The last one would also allow more complex specifications like {2,{a,b,c}} (exactly 2 of a, b and c) or {2;;4, {a,b,c,d,e}} (2 to 4 out of a to e). – celtschk Oct 10 '12 at 18:19
You say you don't want to use And and Or because a and b aren't Boolean -- why not? If they are expressly not Boolean then a && b or a || b will not evaluate, and this format is probably easiest to read. Do you have another reason to avoid these? – Mr.Wizard Oct 10 '12 at 18:43