Download or view shuffleTest.frink in plain text format
/** This tests the array.shuffle[] method for uniform distribution. */
elements = 5
a = array[1 to elements]
results = new dict
count = million
for i=1 to count
{
b = a.shallowCopy[]
b.shuffle[]
if results@b == undef
results@b = 1
else
results@b = results@b + 1
}
println[join["\n",results]]
g = new graphics
g.font["SansSerif", 1]
y = 0
scale = count/(elements!)
for [key, num] = results
{
g.text[key, 0, y, "right", "center"]
g.fillRectSides[0,y-.5,num/scale*100,y+.5]
y = y + 2
}
g.show[]
Download or view shuffleTest.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 13 hours, 16 minutes ago.