Last active
September 22, 2015 17:11
-
-
Save Istar-Eldritch/82b2c1f30ac58752e328 to your computer and use it in GitHub Desktop.
Check if an array of integers is a sequence in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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