Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.35 KB

README.md

File metadata and controls

47 lines (35 loc) · 1.35 KB

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.