SQLExpress - Xb2.NET     ot4xb  
xfree.public
Array
Thread Starter: Osvaldo Ramirez Started: 6/3/2008 8:54 PM UTC
Replies: 1
Array
Hola a todos,

necesito saber si un arreglo tiene mas de 3 elemento iguales en su valor.

Alguien sabe de alguna funcion.

De antemano muchas gracias

-----------------

Hi,

I need to know if some array has more than 3 equals elements ...

Some one has o know a function ?

Thanks in advance
Osvaldo Ramirez
Re: Array
Dear Osvaldo Ramirez

I wrote this function especialy for you ....

function MasDeTresIguales( aArray )
* Begin
  local aConta := {} , i , a
  local nContador , nReturn := 0
  ASort( aArray,,, {|aX,aY| aX[1] > aY[1] } )
  for i := 1 to len( aArray )
    xValue := aArray[i]
    ncontador := 0
    for x := 1 to len( aArray )
      if a[x] = xvalue
         nContador ++
      endif
    next
    aadd( aConta , { xValue , nContador })
  next

  if len( aConta  ) > 0
    ASort( aConta,,, {|aX,aY| aX[2] > aY[2] } )

    if aConta[1][2] > 3
      nReturn := aConta[1][1]
    endif
  endif

return nReturn


 wrote:
Hola a todos,
necesito saber si un arreglo tiene mas de 3 elemento iguales en su valor.
Alguien sabe de alguna funcion.
De antemano muchas gracias
-----------------
Hi,
I need to know if some array has more than 3 equals elements ...
Some one has o know a function ?
Thanks in advance
Osvaldo Ramirez