Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
I use "playlist(directory)" for testing, and by default the mode is randomize. The starting song is "random", but I got many times the same song as first song, too many times for me to believe in randomness (the directory is my mp3 library which is fairly large...).
# let randomize a =
let permute i j =
let tmp = a.(i) in
a.(i) <- a.(j);
a.(j) <- tmp
in
let l = Array.length a in
if l>=2 then
for i=0 to l-2 do
permute i (i + Random.int (l-i))
done
;;
# Random.self_init () ; let a = Array.init 100 (fun i -> i) in randomize a ; a ;;
- : int array =
[|9; 84; 50; 96; 23; 27; 43; 36; 70; 4; 5; 6; 74; 69; 95; 60; 37; 80; 98; 0;
54; 83; 53; 39; 89; 81; 15; 79; 32; 55; 66; 40; 91; 99; 62; 30; 67; 48; 75;
85; 46; 76; 33; 35; 11; 61; 26; 71; 44; 34; 2; 57; 92; 29; 93; 94; 86; 56;
49; 78; 17; 88; 1; 41; 87; 82; 68; 58; 13; 59; 73; 42; 3; 25; 7; 8; 65; 19;
21; 12; 38; 20; 64; 47; 10; 72; 77; 45; 24; 31; 51; 18; 90; 22; 52; 28; 97;
14; 63; 16|]
Repeat it as many times as you want...