Apply |:@:(i.~&>) to an inverted table and work with that.  Quoting from
http://www.jsoftware.com/papers/amuse-bouches.htm#3 ,

... questions of identity on x can often be answered more efficiently on
x⍳x than on x itself.

On Thu, Dec 17, 2015 at 7:21 AM, bill lam <[email protected]> wrote:

> I want an effecient method of finding nub and key of a
> inverted table (rank-1 box array with equal number of
> items in each cells).  eg.
>
>    ]i=. (,.0 2 1 0 2 1 1 1 2 1);10 2$'aaaabaaaabbabbbababb'
> +-+--+
> |0|aa|
> |2|aa|
> |1|ba|
> |0|aa|
> |2|ab|
> |1|ba|
> |1|bb|
> |1|ba|
> |2|ba|
> |1|bb|
> +-+--+
>
> NB. nub of i
>    ifa ~. a=. afi i
> +-+--+
> |0|aa|
> |2|aa|
> |1|ba|
> |2|ab|
> |1|bb|
> |2|ba|
> +-+--+
>
> NB. key of i
>    a i.~ ~.a
> 0 1 2 0 3 2 4 2 5 4
>
> NB. definition of afi and ifa
>    afi
> |:@:(<"_1@>)
>    ifa
> <@(>"1)@|:
>
> Although nub and key can be found using afi/ifa, it involves a
> lot of box, I worry the time and space efficency when the table
> is large.  Can anyone suggest other ways to do it.
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to