Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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'.
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));
}
}
@anonoz

This comment has been minimized.

Copy link

@anonoz anonoz commented Sep 10, 2016

    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));
      }    
  }

Fuck you and your whitespaces bro 😡

@IcedDoggie

This comment has been minimized.

Copy link
Owner Author

@IcedDoggie IcedDoggie commented Sep 10, 2016

var states = [];
for (i = 0; i < powerSetNumber; i++){
states[i] = String.fromCharCode(myChar.charCodeAt(0) + i);
}

@IcedDoggie

This comment has been minimized.

Copy link
Owner Author

@IcedDoggie IcedDoggie commented Sep 10, 2016

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