You're replying to a comment by alpha.

alpha Permalink
October 14, 2008, 08:16

I mostly remember it being unpleasant, and hoped I’d find something more modern and elegant here :-)

Easiest way to do is to observe that for a set of size N, each element in the power set corresponds to a binary vector of length N. For example, for a set of size 3 with elements {A,B,C}

000 --> {}
001 --> {A}
010 --> {B}
111 --> {A,B,C}

So to enumerate the elements of a power set, just iterate over the 2^N possible values of a binary vector of length N.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "halflife3_97": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.