Dear Gretl Community,

I really stuck trying to define a function that gives a power set of a
set. Suppose I have a set S:

S = {"A", "B", "C"}

The associated power set, P(S), is:

P(S) = {{ }, {"A"}, {"B"}, {"C"}, {"A", "B"}, {"A", "C"}, {"B", "C"},
{"A", "B", "C"}}

All that I can think by now (shame on me!) is this:

strings S = defarray("A", "B", "C")
scalar P_S_len = 2^nelem(S)         # the size of the power set
strings P_S = array(P_S_len)         # an array with 8 spaces.

Does anyone have any ideas?

Best,
Henrique Andrade

Reply via email to