---Brian Schott wrote:
> Once I know how to define ndfr, then I want to create a
> binary mask from the result. For example if the I got the
> result 4 5 from ndfr 4r5 then I could produce the following
> mask (1 1 1 1 0), but I want the 1's and 0's more evenly
> distributed, like 1 1 0 1 1.
> 
>    (]{.#&[EMAIL PROTECTED])/4 5  NB. this produces an unbalanced result.
> 1 1 1 1 0
> 
>       From 7r10 I would like one of the following results.
> 
> 1 1 0 1 1 0 1 1 0 1
> 1 0 1 1 0 1 1 0 1 1
> 
>       Ideas?

I'm sure there will be more elegant and tacit solutions, but in the
meantime this explicit verb seems to do the job.

bm=: 3 : 0
  'n d'=. y
  t=. >.n % >:d-n
  d$(>:t) {. t#1
)

   bm 4 5
1 1 0 1 1
   bm 7 10
1 1 0 1 1 0 1 1 0 1

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to