From: Ralph G Selfridge <[EMAIL PROTECTED]>

For just one element I can use
   ((+/ .<)[EMAIL PROTECTED]:)@(+/\)


Not sure about multiple selctions, but for one element you can use
(I. [EMAIL PROTECTED]: * {:)@(+/\)"1
which allows for 0 and non-integral weights.
For multiple selection you may repeat above while updating weight vector with 0 in place of already selected elements.

Something like

NB. caution, pseudocode
pick=: 4 : 0"0 1
 r=.i.0
 for_i. i.x do.
   r=.r,n=.(I. [EMAIL PROTECTED]: * {:)@(+/\) y
   y=.0 n} y
 end.
 r
)


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

Reply via email to