Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,39 +0,0 @@
|
|||
include misc.e
|
||||
|
||||
function mode(sequence s)
|
||||
sequence uniques, counts, modes
|
||||
integer j,max
|
||||
uniques = {}
|
||||
counts = {}
|
||||
for i = 1 to length(s) do
|
||||
j = find(s[i], uniques)
|
||||
if j then
|
||||
counts[j] += 1
|
||||
else
|
||||
uniques = append(uniques, s[i])
|
||||
counts = append(counts, 1)
|
||||
end if
|
||||
end for
|
||||
|
||||
max = counts[1]
|
||||
for i = 2 to length(counts) do
|
||||
if counts[i] > max then
|
||||
max = counts[i]
|
||||
end if
|
||||
end for
|
||||
|
||||
j = 1
|
||||
modes = {}
|
||||
while j <= length(s) do
|
||||
j = find_from(max, counts, j)
|
||||
if j = 0 then
|
||||
exit
|
||||
end if
|
||||
modes = append(modes, uniques[j])
|
||||
j += 1
|
||||
end while
|
||||
return modes
|
||||
end function
|
||||
|
||||
constant s = { 1, "blue", 2, 7.5, 5, "green", "red", 5, 2, "blue", "white" }
|
||||
pretty_print(1,mode(s),{3})
|
||||
Loading…
Add table
Add a link
Reference in a new issue