Created
September 10, 2016 17:21
-
-
Save IcedDoggie/c665c71814ce4801f354bba2f7af4cfd to your computer and use it in GitHub Desktop.
function call as: string_recursive(array, "", statesInString), statesInString and the empty string are constant in this case. The expected output should alert a pop-up with 'Z'.
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
var powerSets = new Array(); | |
powerSets.push("Z"); | |
var statesInString = states.join(''); | |
statesInString = statesInString.substring(0, numLines); //take the NFA string only | |
string_recursive(powerSets,"",statesInString); | |
alert(powerSets[0]); | |
// for(i = 0; i<powerSetNumber ; i++){ | |
// alert(powerSets[i]); | |
// } | |
} | |
function string_recursive($powerSetNumber, $output, $leftOvers){ | |
if($leftOvers.length == 0 && $output!="") | |
{ | |
$powerSetNumber.push($output); | |
console.log(powerSets); | |
} | |
else | |
{ | |
string_recursive($powerSetNumber ,$output + $leftOvers.charAt(0), $leftOvers.substring(1, $leftOvers.length)); | |
string_recursive($powerSetNumber ,$output, $leftOvers.substring(1, $leftOvers.length)); | |
} | |
} |
var states = [];
for (i = 0; i < powerSetNumber; i++){
states[i] = String.fromCharCode(myChar.charCodeAt(0) + i);
}
For function call: example: string_recursive(powerSets, "", statesInString);
2nd sample: string_recursive(powerSets,"","abc");
3rd sample: string_recursive(powerSets,"", "abcd")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fuck you and your whitespaces bro 😡