From: Greg W. <gre...@gm...> - 2006-10-08 22:20:40
|
On 10/8/06, Daniel Mahler <dm...@gm...> wrote: > > >>> a > array([0, 0]) > >>> b > array([0, 1, 0, 1, 0]) > >>> c > array([1, 1, 1, 1, 1]) > Well for this particular example you could do a=array([len(b)-sum(b), sum(b)]) Since you are just counting the ones and zeros. This next one is a little closer for the case when c is not just a bunch of 1's but you still have to know how the highest number in b. a=array([sum(c[b==0]), sum(c[b==1]), ... sum(c[b==N]) ] ) So it sort of depends on your ultimate goal. Greg -- Linux. Because rebooting is for adding hardware. |