Re: Comparing a matrix (list[][]) ?

2007-01-14 Thread Colin J. Williams
jairodsl wrote: Hi, How can I find the minus element greater than zero in a matrix, my matrix is matrix= [9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5] I dont want to use min function because each element in the matrix is associated to (X,Y) position. Thanks a lot. jDSL

Comparing a matrix (list[][]) ?

2007-01-13 Thread jairodsl
Hi, How can I find the minus element greater than zero in a matrix, my matrix is matrix= [9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5] I dont want to use min function because each element in the matrix is associated to (X,Y) position. Thanks a lot. jDSL --

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread Roberto Bonvallet
jairodsl wrote: How can I find the minus element greater than zero in a matrix, my matrix is matrix= [9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5] I dont want to use min function because each element in the matrix is associated to (X,Y) position. What output are you expecting

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread bearophileHUGS
Roberto Bonvallet: What output are you expecting from your example matrix? If you are expecting it to be 5 (the smallest positive element), using min is the way to do it: matrix = [[9, 8, 12, 15], ... [0, 11, 15, 18], ... [0, 0, 10, 13], ...

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread jairodsl
Ok, the main idea is compare each element with others elements, and go saving the minus element positive and his position (X,Y) in the matrix, of course min function dont let me save this position (X,Y). I dont know if its possible do that with min function. jDSL Roberto Bonvallet wrote: What

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread jairodsl
Thanks a lot, it was that i need !!! Works very good ! [EMAIL PROTECTED] wrote: Roberto Bonvallet: What output are you expecting from your example matrix? If you are expecting it to be 5 (the smallest positive element), using min is the way to do it: matrix = [[9, 8, 12, 15],

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: mat = [[9, 8, 12, 15], ..., [0, 0, 0, 5]] print min(el for row in mat for el in row if el 0) ... If the OP needs the position he/she can do something like: iterative solution Or you can still use min by keeping the position after the value: value,