comparison js/core.js @ 2833:47f187d4fc71

Fix for #210
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 26 Jun 2017 11:58:59 +0100
parents cf1a3a529177
children 033027759cf7
comparison
equal deleted inserted replaced
2832:740f273226c3 2833:47f187d4fc71
1196 function pickSubPool(pool, numElements) { 1196 function pickSubPool(pool, numElements) {
1197 // Assumes each element of pool has function "alwaysInclude" 1197 // Assumes each element of pool has function "alwaysInclude"
1198 1198
1199 // First extract those excluded from picking process 1199 // First extract those excluded from picking process
1200 var picked = []; 1200 var picked = [];
1201 pool.forEach(function (e) { 1201 pool.forEach(function (e, i) {
1202 if (e.alwaysInclude) { 1202 if (e.alwaysInclude) {
1203 picked.push(e); 1203 picked.push(pool.splice(i, 1)[0]);
1204 } 1204 }
1205 }); 1205 });
1206 1206
1207 return picked.concat(randomSubArray(pool, numElements - picked.length)); 1207 return picked.concat(randomSubArray(pool, numElements - picked.length));
1208 } 1208 }