function sample_floyd(m, list) {
  var s = []; 
  var n = list.length - 1;
  for (var idx = n - m + 1; idx <= n; ++idx) {
    var candi = list[Math.floor(Math.random() * idx)];
    s.push(!~s.indexOf(candi) ? candi : list[idx]);
  }
  return s;
}
// From the book "More Programming Pearls"
From the book "More Programming Pearls"
From the book " More Programming Pearls "
function sample_floyd(m, list) {
  var s = []; 
  var n = list.length - 1;
  for (var idx = n - m + 1; idx <= n; ++idx) {
    var candi = list[Math.floor(Math.random() * idx)];
    s.push(!~s.indexOf(candi) ? candi : list[idx]);
  }
  return s;
}
function sample_floyd ( m , list ) { var s = [ ] ; var n = list . length - 1 ; for ( var idx = n - m + 1 ; idx <= n ; ++ idx ) { var candi = list [ Math . floor ( Math . random ( ) * idx ) ] ; s . push ( ! ~ s . indexOf ( candi ) ? candi : list [ idx ] ) ; } return s ; }
From the book "More Programming Pearls"
From the book " More Programming Pearls "