Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-22 Thread Fabian Jakobs
Petr Kobalíček schrieb: > Sorry for opening this topic (I noticed accepted bug in bugzilla and I > don't know how to add comment there) > You need to be logged in to comment on bugs. You can create an account here: It would be great if you could

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-21 Thread Petr Kobalíček
Sorry for opening this topic (I noticed accepted bug in bugzilla and I don't know how to add comment there) This is small test case how browsers works: // TEST 1 var arr = [1, 2, 3, 4]; arr.length = 0; alert(arr[0]); // undefined // TEST 2 var arr = {}; arr.length = 3; arr[0] = 1; arr.length =

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-14 Thread Fabian Jakobs
Petr Kobalíček schrieb: > Yes, it's #1171 > thank you > 2008/8/14 Fabian Jakobs <[EMAIL PROTECTED]>: > >> Petr Kobalíček schrieb: >> >>> Hi Guilherme, >>> >>> I have another way :-) >>> >>> max : function(arr) >>> { >>> var i, len=arr.length, result = arr[0]; >>> for

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-14 Thread Petr Kobalíček
Yes, it's #1171 2008/8/14 Fabian Jakobs <[EMAIL PROTECTED]>: > Petr Kobalíček schrieb: >> Hi Guilherme, >> >> I have another way :-) >> >> max : function(arr) >> { >> var i, len=arr.length, result = arr[0]; >> for (i = 1; i < len; i++) if (arr[i] > result) result = arr[i]; >>

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-14 Thread Fabian Jakobs
Petr Kobalíček schrieb: > Hi Guilherme, > > I have another way :-) > > max : function(arr) > { > var i, len=arr.length, result = arr[0]; > for (i = 1; i < len; i++) if (arr[i] > result) result = arr[i]; > return result; > } > > min : function(arr) > { > v

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-13 Thread Petr Kobalíček
Hi Guilherme, I have another way :-) max : function(arr) { var i, len=arr.length, result = arr[0]; for (i = 1; i < len; i++) if (arr[i] > result) result = arr[i]; return result; } min : function(arr) { var i, len=arr.length, result = arr[0]; for

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-13 Thread Guilherme Aiolfi
but [ 0 ] has values. But that's is another problem, before return "result" it should do a test. Here is "max" function the way I think it should be: max : function(arr) { var result = Number.NEGATIVE_INFINITY; for (var i=0, l=arr.length; i result) { result = arr[i];

Re: [qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-13 Thread Petr Kobalíček
Hmm, If array hasn't values, shouldn't it result null or undefined instead of 0 ? 2008/8/13 Guilherme Aiolfi <[EMAIL PROTECTED]>: > Hi, > > I was trying to use qx.lang.Array.max and it is not doing what I want. > Looking at the code, those 2 functions use statics values from Number class: > > var

[qooxdoo-devel] [0.8] Array.max and Array.min

2008-08-13 Thread Guilherme Aiolfi
Hi, I was trying to use qx.lang.Array.max and it is not doing what I want. Looking at the code, those 2 functions use statics values from Number class: var result = Number.MIN_VALUE; (for max method) and var result = Number.MAX_VALUE; (for min method) so, if an array has [ 0 ] (or a negative val