Skip to content

Instantly share code, notes, and snippets.

@Istar-Eldritch
Last active September 22, 2015 17:11
Show Gist options
  • Save Istar-Eldritch/82b2c1f30ac58752e328 to your computer and use it in GitHub Desktop.
Save Istar-Eldritch/82b2c1f30ac58752e328 to your computer and use it in GitHub Desktop.
Check if an array of integers is a sequence in JS
function isSeq(list, f = list.shift()) {
if(list.length == 0) {
return true;
}
else if(list[0] != f + 1) {
return false;
}
else {
return isSeq(list, list.shift());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment