On Sat, Aug 1, 2009 at 5:19 AM, Kip Murray<[email protected]> wrote:
>    powerSet ''     NB. would like this to be <''
> |length error: powerSet
> |       powerSet''

> Raul Miller wrote:
>>    powerSet=: <@#~ 2#:@i...@^#


Hmm... yes.
   2^#''
1
   #:i.1
0

The problem is the traditional leading zero which
we get from #: instead of a mathematically
consistent empty list  of bits.

Adverse seems like the simplest approach for dealing
with this issue.  And, since you wanted
sorted sets, I can throw in a sort also:
   powSet=:    /:~@(<@#~ 2#:@i...@^#) ::(a:"_)

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

Reply via email to