What about 

   e ((]-.]-.[))&(20 $]) pi
3 1 1 2 3 1 1 2 3 1

with 

   e (,.@;)&([:/:~ 20 $]) pi
+---------------------------------------+
|1 1 1 1 2 2 2 2 2 3 3 7 7 7 8 8 8 8 8 8|
+---------------------------------------+
|1 1 1 1 1 2 2 3 3 3 4 4 5 5 5 5 6 6 9 9|
+---------------------------------------+

Obviously wrong.

We had a similar question in 2004: 
http://www.jsoftware.com/pipermail/general/2004-May/017427.html 
The question here appears to be the intersection of two multisets or bags  
http://en.wikipedia.org/wiki/Multiset 
Conform http://www.jsoftware.com/pipermail/general/2004-May/017490.html   one 
should take the minimum of the nubcounts and
reconstruct the intersection from that.

im=:intrsct_mltsts=: 4 : 0      NB. intersection of multisets
 nbint =. x ([-.-.)&~. y
 x (nbint #~ <. &(nbint ((i.~ {.) { {:@]) ]))&([:|:({.,#)/.~) y
)

   e im&(20 $]) pi
2 2 1 1 1 1 3 3

   e im&(20 $])~ pi
3 3 1 1 1 1 2 2


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@jsoftware.com 
> [mailto:programming-boun...@jsoftware.com] Namens Linda Alvord
> Verzonden: zaterdag 2 juni 2012 11:24
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] rank trouble
> 
> 
>     pi=: 3 1 4 1 5 9 2 6 5
>     e=: 2 7 1 8 2 8 1 8 3
> 
>    pi (]-.]-.[) e
> 2 1 2 1 3
>    e ([ -. -.) pi
> 2 1 2 1 3
> 
> Since there is only one  2   in the nine digits of  pi  , isn't the only
> correct one?
> 
>    e (]-.]-.[) pi
> 3 1 1 2
> 
> Linda
> 
> 
> -----Original Message-----
> From: programming-boun...@jsoftware.com
> [mailto:programming-boun...@jsoftware.com] On Behalf Of Alexander Mikhailov
> Sent: Friday, June 01, 2012 1:35 PM
> To: programming@jsoftware.com
> Subject: Re: [Jprogramming] rank trouble
> 
> 
> -----
> Without the "nub" gives an arguably more correct answer:
> 
>    pi (]-.]-.[) e
> 2 1 2 1 3
>    e (]-.]-.[) pi
> 3 1 1 2
> -----
> 
> Why not
> 
> e ([ -. -.) pi
> 2 1 2 1 3
> ?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> 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