Question: Power set

Hello everybody,

 

I have a list of 8 integers and I want to extract all the possible sublists of this list.

For example if the list is L:=[1,2,3,4,5,6,7,8] I want to extract

[1,3,5]

[7]

[2,3,7,8]

etc.

Is there a simple way to do that? Since there are 2^8=256 of such sublists, my idea was to

write a for i  from 1 to 256 and convert i to a binary number on each iteration, e.g, i =123

is the binary number 1111011, which would correspond to sub list

[1,2,3,4,6,7]. Unfortunately I don´t know which maple functions I can use do

perform that operation. Any help???

Thanks in advance,

Bernardo

 

Please Wait...