Repeat and count ... but fastest! (='.'=)
Posted: Thu May 04, 2017 6:43 pm
Hello to all!!!
I'm doing a little experiment.
I have a list of words and phrases:
hello
hello
hello
ciao
miao
miao
miao
miao
uurgh!
uurg!
song
song and sing
song and sing
I would like to count the duplicates of this list and put them in order in another list.
4|miao
3|hello
2|song and sing
1|ciao
1|uurgh!
Simple, I said! But in fact if the number of elements of the list to be analyzed increases, the job becomes very slow.
Is there an alternative to mine algo?
Thanks for those who want to give me some help!
Here is my proud code!:
Peace and love at all!
(='.'=)
Mariasole
I'm doing a little experiment.

I have a list of words and phrases:
hello
hello
hello
ciao
miao
miao
miao
miao
uurgh!
uurg!
song
song and sing
song and sing
I would like to count the duplicates of this list and put them in order in another list.
4|miao
3|hello
2|song and sing
1|ciao
1|uurgh!
Simple, I said! But in fact if the number of elements of the list to be analyzed increases, the job becomes very slow.

Is there an alternative to mine algo?

Thanks for those who want to give me some help!
Here is my proud code!:
Code: Select all
on mouseUp
// a. initialize...
put empty into LineMatchCount
put empty into field "RepeatList"
// b, load field into variable in memory for fastest ;)
put field "OriginalList" into tOriginalList
// c. Repeat for each line
repeat for each line tLine in tOriginalList
-- copy tLine into tMatch
put tLine into tMatch
-- repeat in list for count duplicate line
repeat for each line yLine in tOriginalList
-- if match then add 1 to LineMatchCount
if yLine is tMatch then
add 1 to LineMatchCount
end if
end repeat
-- put the number of repeat and the key line & return
put LineMatchCount & "|" & tLine after field "RepeatList"
put return after field "RepeatList"
-- initialize variable
put empty into LineMatchCount
end repeat
// d. Dedupe RepeatList
-- I still have to work!
//e. sort list RepeatList
-- I still have to work!
end mouseUp
Peace and love at all!
(='.'=)
Mariasole