Raul,
powSet=: /:~@:(<@#~) 2 (#"1 +./)@#:@i...@^#
]e =: powSet 'ab'
++-+-+--+
||a|a|ab|
++-+-+--+
$&.> e
+-+-+-+-+
|0|1|1|2|
+-+-+-+-+
Verb powSet applied to vector 'ab' quite properly returns subsets which are
vectors. Now look at
]M =: 2 1 $ 'ab'
a
b
]e2 =: powSet M
+-+-+-+-+
| |a|a|a|
| | | |b|
+-+-+-+-+
$&.> e2
+---+---+---+---+
|0 1|1 1|1 1|2 1|
+---+---+---+---+
Verb powSet M quite properly returns shape k,1 subsets for shape 2 1 array M.
But why doesn't < 1 1 $ 'b' appear in e2?
Kip
Raul Miller wrote:
>
> Here's a variation which eliminates the bogus leading zero from #:
>
> powSet=: /:~@:(<@#~) 2 (#"1 +./)@#:@i...@^#
>
> (and still sorts the results)
>
> FYI,
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm