Probably not the shortest approach, but I’d probably do either this…
function countItemRepsInList pList, pItem
replace comma with cr in pList
filter pList with pItem
return (the number of lines in pList)
end countItemRepsInList
or this
function countItemRepsInList pList, pItem
put 0 into tCount
repeat for each item tItem in pList
if (tItem = pItem) then add 1 to tCount
end repeat
return tCount
end countItemRepsInList
Terry
From: use-livecode <[email protected]> on behalf of Roger
Guay via use-livecode <[email protected]>
Date: Friday, 24 May 2024 at 12:09 PM
To: How to use LiveCode <[email protected]>
Cc: Roger Guay <[email protected]>
Subject: Return Total of a Given Repeated Number in a List
Hi all,
Please, what’s the easiest way to return the total number of a given repeated
number in a list of numbers? IOW, how many times is 2 repeated in a list
containing 1,2,3,2,4,2,5,2,8 etc. Appreciate your help.
Thanks,
Roger
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode