] x=: 20 ?...@$ 7
6 2 1 2 6 5 6 1 3 0 0 4 3 3 5 1 2 5 5 5
   <: #/.~ (i.7) ,x
2 3 3 3 1 5 3

This is assuming you know "the universe" that should
be prefaced to x before the application of #/.~ .



----- Original Message -----
From: Zsbán Ambrus <[email protected]>
Date: Sunday, September 5, 2010 12:01
Subject: [Jprogramming] Mask from list of indices with multiplicity
To: [email protected]

> If I have a list of indices with possible repetitions, such as
> 
>    i=: 1 3 1
> 
> how do I convert it to a mask m so that n{m is the number of
> occurrences of n in i ?
> 
>    m=: +/ i =/ i. >: >./ i
> 0 2 0 1
> 
> I can convert from the mask to the (sorted) list of indices with the
> I. builtin, eg.
> 
>    I. m
> 1 1 3
> 
> but is there a simpler way for the conversion to mask?  
> Would it make
> sense if I.^:_1 did this?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to