Skip to content

chakri68/theoryOfComputation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Theory of Computation

Codes that perform various tasks I learnt in theory of computation course

Grammar class

This class can be used to create a grammar object.

Constructor

constructor(variables, rules, startVariable) {
    this.variables = variables;
    this.rules = rules;
    this.startVariable = startVariable;
  }
  • variables -> Array of characters that are variables
  • rules -> Object of the form {variable: "variables_and_terminals"}
  • startVariable -> The variable that is to be used to generate strings

Methods

checkForVariables

checkForVariables(str);
  • str -> The string to check variables in
  • Returns true if the string contains a variable else returns false

getVariables

getVariables(str);
  • str -> The string to get variables from
  • Returns a list of all variables the string contains

canDecrease

canDecrease(arr);
  • arr -> An array containing variables
  • Returns true if any of the variables can be reduced to an empty string else returns false

Language class

This class is used to generate a language object

Constructor

constructor(grammar) {
    this.grammar = grammar;
  }
  • grammar -> A grammar object

Methods

generateStringbyLength

generateStringbyLength(n, (currString = null));
  • n -> The length of the string
  • Prints out the strings that satisfy the conditions

Jdoodle link

https://www.jdoodle.com/ia/vkz

About

Codes that perform various tasks I learnt in theory of computation course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published