Hi,

To generate all subsets of set s:
this is what I can come up with:

   powerset=: 13 : '(#: i.2^#y)<@:#"1 y'
 
   a =: 1 2 3 4

   powerset a
++-+-+---+-+---+---+-----+-+---+---+-----+---+-----+-----+-------+
||4|3|3 4|2|2 4|2 3|2 3 4|1|1 4|1 3|1 3 4|1 2|1 2 4|1 2 3|1 2 3 4|
++-+-+---+-+---+---+-----+-+---+---+-----+---+-----+-----+-------+

... and:

   ts 'it=:powerset 1+ i.20'
2.73689 2.60676e8
   #it
1048576

Can someone produce another verb 'powerset' because
it looks to me that I use to much resources.


Thanks

@@i=Arie

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to