Skip to content

Instantly share code, notes, and snippets.

@br0xen
Created March 14, 2014 14:18
Show Gist options
  • Save br0xen/9548547 to your computer and use it in GitHub Desktop.
Save br0xen/9548547 to your computer and use it in GitHub Desktop.
devict.org Code Challenge - Partition On
function partitionOn(pred, items) {
var sp_idx = 0;
for(var i in items) {
if(!pred(items[i])) {
// If the predicate is false, move it to sp_idx, otherwise, leave it.
items.splice((sp_idx++), 0, items.splice(i, 1)[0]);
}
}
return sp_idx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment