Re: Reporting the number of duplicates in a list of numbers?

2014-05-05 Thread Alex Tweedly
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
  else
 if tLast is not empty then put tLast  tCount CR after tCounted
 put L into tLast
 put 1 into tCount
  end if
end repeat
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.



-- Alex.

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:
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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reporting the number of duplicates in a list of numbers?

2014-05-04 Thread Kay C Lan
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 johnpat...@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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Reporting the number of duplicates in a list of numbers?

2014-05-04 Thread JOHN PATTEN
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.macm...@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 johnpat...@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@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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reporting the number of duplicates in a list of numbers?

2014-05-04 Thread Peter Haworth
If you're using an sql  db:

SELECT thewordnumber, count(*) AS C FROM table GROUP BY  thewordnumber
 ORDER BY C DESCENDING

Returns the word numbers and count sorted by count high to low.

Pete
lcSQL Software
On May 4, 2014 8:47 PM, JOHN PATTEN johnpat...@me.com wrote:

 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.macm...@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 johnpat...@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@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@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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode