如何使用 LiveCode 在数组中显示重复的单词
How to display repeated words in an array using LiveCode
我是 LiveCode 的初学者。我如何在数组中显示重复的单词及其计数。可能吗?
global ar
on mouseUp
--answer ar
//ar contain some text
put ar into s1
split s1 by CR
put the number of lines of (the keys of s1) into s2
repeat for each word k in s1
put s1[k] into k1
split k1 by CR
end repeat
answer k1[1]
end mouseUp
repeat for each key j in myArrayT
put myArrayT[j] into k
split k by colon
创建一个字段并用一堆单词填充它,其中许多重复一次或多次。将该字段命名为 "wordList"。现在在按钮脚本中:
on mouseUp
get fld "wordList"
repeat for each word tWord in it
add 1 to wordCount[tword]
end repeat
combine wordCount by return and comma
answer wordCount
end mouseUp
我是 LiveCode 的初学者。我如何在数组中显示重复的单词及其计数。可能吗?
global ar
on mouseUp
--answer ar
//ar contain some text
put ar into s1
split s1 by CR
put the number of lines of (the keys of s1) into s2
repeat for each word k in s1
put s1[k] into k1
split k1 by CR
end repeat
answer k1[1]
end mouseUp
repeat for each key j in myArrayT
put myArrayT[j] into k
split k by colon
创建一个字段并用一堆单词填充它,其中许多重复一次或多次。将该字段命名为 "wordList"。现在在按钮脚本中:
on mouseUp
get fld "wordList"
repeat for each word tWord in it
add 1 to wordCount[tword]
end repeat
combine wordCount by return and comma
answer wordCount
end mouseUp