Skip to content

Python library for visualizing recursive function calls in the console.

License

Notifications You must be signed in to change notification settings

cabralpinto/trevis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trevis

Easily visualize recursive functions in the console.

from trevis import recursion

@recursion
def fib(n: int) -> int:
    if n < 2: return n
    return fib(n - 1) + fib(n - 2)

fib(4)
# output
fib(4) → 3
├╴fib(3) → 2
│ ├╴fib(2) → 1
│ │ ├╴fib(1) → 1
│ │ └╴fib(0) → 0
│ └╴fib(1) → 1
└╴fib(2) → 1
  ├╴fib(1) → 1
  └╴fib(0) → 0

Features

  • 🕹️ Interactive mode: Review each function execution interactively, advancing to the next step by pressing Enter. This mode enhances comprehension and debugging by providing a clear visual representation of each step. Enable with recursion(interactive=True).
  • 🌈 Syntax highlighting (upcoming): Enable syntax highlighting in the tree for improved readability. Coming in a future version.
  • 🎲 Non-deterministic function visualization (upcoming): Visualize of all possible execution paths for non-deterministic functions. Coming in a future version.

Installation

Ensure you have Python 3.6 or higher, then install Trevis using pip:

pip install trevis

Contribution

Contributions are welcome! Feel free to submit an issue or pull request.

License

Trevis is licensed under the MIT License.

About

Python library for visualizing recursive function calls in the console.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages