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
[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:
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,
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
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],
> ...
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 e
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
--
http://mail.python.org/mailma