core/lib/weighted-pick.js
function create(list) {
  let dist = l.reduce(list, function(acc, el, i) {
    for(let j = 0; j < el.weight * 100; j++) {
      acc.push(i);
    }
    return acc;
  }, []);

  return function() {
    let i = dist[l.random(0, dist.length - 1)];
    return [i, list[i]];
  };
}
function create(list) {
  let dist = l.reduce(list, function(acc, el, i) {
    for(let j = 0; j < el.weight * 100; j++) {
      acc.push(i);
    }
    return acc;
  }, []);

  return function() {
    let i = dist[l.random(0, dist.length - 1)];
    return [i, list[i]];
  };
}
function create ( list ) { let dist = l . reduce ( list , function ( acc , el , i ) { for ( let j = 0 ; j < el . weight * 100 ; j ++ ) { acc . push ( i ) ; } return acc ; } , [ ] ) ; return function ( ) { let i = dist [ l . random ( 0 , dist . length - 1 ) ] ; return [ i , list [ i ] ] ; } ; }
naive implementation of selection with replacement
naive implementation of selection with replacement