Reporting the number of duplicates in a list of numbers?

JOHN PATTEN johnpatten at me.com
Sun May 4 23:47:15 EDT 2014


Thanks Kay!

That’s what I needed. I knew it was pretty simple, but my unfamiliarity with arrays prevented me from seeing the solution. 

Cheers!

John Patten
SUSD

On May 4, 2014, at 8:14 PM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:

> This might get you started, in the msg box:
> 
> put "3,5,6,6,24,24,24,33,130,109" into tData
> --if the data comes from the db as seperate lines, then
> --repeat for each line tRecord in tData
> --if data comes in from db as a list
> repeat for each item tRecord in tData
> add 1 to aCount[tRecord]
> end repeat
> --now output results
> repeat for each key tKey in aCount
>  put tKey & " = " & aCount[tKey] & cr after msg
> end repeat
> 
> The output I get is:
> 
> 109 = 1
> 3 = 1
> 130 = 1
> 5 = 1
> 33 = 1
> 24 = 3
> 6 = 2
> 
> HTH
> 
> 
> 
> 
> On Mon, May 5, 2014 at 10:58 AM, JOHN PATTEN <johnpatten at me.com> wrote:
> 
>> Hi All…
>> 
>> I am attempting to get the total number of times specific words in a text
>> passage are selected by students. The way I’m doing this is by recording
>> the word numbers selected by each student and storing them in a database.
>> I end up with list of numbers representing the selected words, something
>> like this:
>> 3
>> 5
>> 6
>> 6
>> 24
>> 24
>> 24
>> 33
>> 130
>> 109
>> … etc. etc. I would like to determine the number of times the same words
>> are selected by the students and then control their font size, make the
>> font size larger the more often the text is selected. So the teacher’s
>> report would be the same passage of text with the font sizes of the text
>> increased based on how many times the word was selected by the students.
>> 
>> I’m not sure how to get the counts for the selected words. These list of
>> word numbers could be quite long, depending on how many students are in the
>> class and the length of the passage. I have not done anything like this
>> before so I’m looking for any advice. Should I be dumping the list into an
>> array and then working some kind of array magic? Can I just use a repeated
>> find script and increment a variable for each item in my list?
>> 
>> I didn’t want to spin my wheels too long, and this is probably pretty
>> basic, but I can’t remember coding a solution to something like this in the
>> past.
>> 
>> Thank you!
>> John Patten
>> SUSD
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list