Averages/Mode: Difference between revisions

Content deleted Content added
Line 1,615:
 
<lang M2000 Interpreter>
Module Checkit {
Function GetMode {
LocalFunction max%GetMode(&a()){
if empty then =(,) : exit Local max%
dim if len(a())=0 then =(,)
n%=len(a()=Array([])
n dim c%=len(a()n%)
dim c For i%(=0 to n%)-2
For ij%=0i%+1 to n%-21
For j if a(i%)=i=a(j%+1) tothen nc%-1(i%)++
ifNext a(i%)==a(j%) then c%(i%)++
Next j If c%(i%)>max% Then max%=c%(i%)
IfNext c%(i%)>max% Then max%=c%(i%)
Next For i%=0 to n%-1
For If c%(i%) =0 tomax% nThen Data a(i%-1)
IfNext c%(i%) = max% Then Data a(i%)
Next i% =Array([])
=[]}
Dim Am(5)
m()=(2,3,43,234,234,3,324)
Print GetMode(!&m()) ' print 13 4234
k=(1,2,1,2,1,2,3)
n=GetMode(&k)
' iterate backward
i=each(m, -1, 1)
While i {
Print Array(i),
}
Print
}
Print GetMode(1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17) 'print 6
Dim A(5)
A(0)= 1, 2, 4, 4, 1
m=A()
Print GetMode(!m) ' print 1 4
</lang>