Skip to content

🌲 Reading and writing of a string tree bracket representation

Notifications You must be signed in to change notification settings

urgas9/tree-bracket-representation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree-bracket-representation

Test & Lint all

Reading and writing of a string tree bracket representation in multiple programming languages.

What is this project about?

It is a simple hoby project, created mainly to learn new tools, languages and to be able to directly compare pros and cons of each language. So there will be many solutions in the repo, divided by programming languages, e.g. java and go.

The goal of the program is to read and write tree structure from a bracket string representation. Read more on the representation from this link but bare in mind that this library supports reading and writing of general trees as well.

For example, the below tree:

        A
    /   |   \
  CD    E    I
       / \
      F   G

could simply be presented as:

A(CD)(E(F)(G))(I)

on the other hand, here are some examples of invalid tree strings:

A(CD)a      // there is undefined node a
()          // two errors: the root node and its first child have no name
(A)         // the root node has no name

See more valid and invalid examples in the files used for tests across different implementations in ./examples folder.

Requirements

Each language should add support for the following function:

  • object constructor: parses a bracket tree string representation to an internal object structure and stores initial bracket tree string
  • find("A"): finds the first occurrence of node with name A and returns object presentation of the node
  • addChild("D(C(M))(L)"): adds child D to the tree node
  • countLeaves(): returns a number of nodes that have no children
  • toBracketRepresentation(): converts the internal object structure back to bracket tree string representation

For each language there should also be:

  • written tests that read invalid and valid test cases from JSON files stored in ./examples folder.
  • a linting tool to be added to check for code style.
  • the execution of tests and lint tool should be included in GitHub Actions workflow file.
  • written README.md file with status and example usage

How to use?

Check each for a README file in each language's folder.

About

🌲 Reading and writing of a string tree bracket representation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published