Very nice, Raul!
<1 NB. a set (without set-marker)
+-+
|1|
+-+
powerSet <1 NB. as expected:
++---+
||+-+|
|||1||
||+-+|
++---+
powerSet^:2 <1 NB. also as expected:
++-----+--+------+
||+---+|++|++---+|
|||+-+|||||||+-+||
||||1|||++||||1|||
|||+-+|| |||+-+||
||+---+| |++---+|
++-----+--+------+
powerSet '' NB. would like this to be <''
|length error: powerSet
| powerSet''
P.S. sleepless night
Raul Miller wrote:
> On Fri, Jul 31, 2009 at 9:04 PM, Kip Murray<[email protected]> wrote:
>> The power set of a set is the new set comprising all subsets of the original
>> set.
>
> powerSet=: <@#~ 2#:@i...@^#
> powerSet 'abc'
> ++-+-+--+-+--+--+---+
> ||c|b|bc|a|ac|ab|abc|
> ++-+-+--+-+--+--+---+
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm