Reporting the number of duplicates in a list of numbers?
alex at tweedly.net
Mon May 5 10:07:30 EDT 2014
I'm the biggest fan there is of arrays - but for this problem an array
looks like overkill - see the simple code below.
(btw - not actually tested, so beware typos)
put empty into tCounted
put empty into tLast
repeat for each line L in tData
if L = tLast then
add 1 to tCount
if tLast is not empty then put tLast && tCount &CR after tCounted
put L into tLast
put 1 into tCount
put tLast && tCount &CR after tCounted
As an aside, either this method or the other one Kay posted using arrays
would work just as well using the actual word, rather then "numbers
representing the selected word", so if you had to do any work to convert
the students' input from word to number, you could skip that step.
On 05/05/2014 03:58, JOHN PATTEN 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:
> … 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
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode