raganwald/balanced-parentheses

Code exploring Dyck Languages

★ 0Forks 0TypeScriptGitHub ↗Compare

README

balanced-parentheses

Exploring the generation of words in Dyck Languages

unstated constraints

  • bijection, which means no duplicates
  • finite number for every finite pair or triple, which rules out certain mappings

potential exercises

  • prove that this generation can never produce two words with the same rendering but different composition.
    • discover that ww* is not helpful for generating a unique mapping
  • prove that a nested for loop cannot work
  • parse a dyck word/validate a dick word using the construction
  • every non-empty dyck word has an intial word of the form X...Y followed by empty or another dyck word this should facilitate parsing.
  • dyck languages with depth limits

mapping dyck words to nonnegatives

"Here is a string, give me the first complete Dyck Word and the remander of the string"

bibliography

“In the theory of formal languages of computer science, mathematics, and linguistics, a Dyck word is a balanced string of brackets. The set of Dyck words forms a Dyck language. The simplest, Dyck-1, uses just two matching brackets, e.g. ( and ).” --Wikipedia

“In days of yore, it was common to ask junior programmers a ‘fizzbuzz’ question to test extremely basic ability to write code.” One such question was, “Write a function that takes as its argument a string, and returns whether the string contains balanced parentheses.” --Alice and Bobbie and Sharleen and Dyck

“The relationship between the types of machines that recognize valid expressions in a language, classes of computation, and classes of language grammars is extremely interesting, even if the some of the essays written about it are brutal.” --A Brutal Look at Balanced Parentheses, Computing Machines, and Pushdown Automata

"Pattern Matching and Recursion" approaches balanced parentheses from the perspective recursively defining words in the language --Pattern Matching and Recursion

Contributors

raganwald

Issues