Well, you could do something like this (caution: untested e-mail Lingo)...
-- aList = #linearList or #propList
-- returns a #propList where
-- property is a value from aList
-- value is the number of occurrences of that aList value
on mListValuesCounts ( aList )
if not ilk ( aList, #list ) then return #error
tResultList = [:]
tList = aList.duplicate ( )
repeat while tList.count ( ) > 0
iVal = tList [ 1 ]
iCount = 1
tList.deleteAt ( 1 )
jIdx = tList.getPos ( iVal )
repeat while jIdx > 0
iCount = iCount + 1
tList.deleteAt ( jIdx )
jIdx = tList.getPos ( iVal )
end repeat
tResultList.setaProp ( iVal, iCount )
end repeat
tResultList.sort ( )
return tResultList
end
HTH,
Jeff
At 1509 -0300 06/30/2005, Rods wrote:
>Hi,
>
>How is the best way to count the occurrences of values in a list? I have a
>list with 6000+ random generated numbers and I need to count how many times
>each of one appear.
>
>Thank's in advance
>
>
>Rodrigo Peres
>...
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]