cheran-senthil / PyRival

⚡ Competitive Programming Library
https://pyrival.readthedocs.io/
Apache License 2.0
1.17k stars 312 forks source link

add version of bootstrap that transforms source #63

Closed Mukundan314 closed 3 years ago

Mukundan314 commented 3 years ago

Transformations it does

Inside bootstrapped function:

Outside bootstrapped functions:

Caveats

Example Transformation

Original Transformed
```python @bootstrap def abc1(n): if n == 0 or n == 1: return 1 return abc2(n - 1) + n @bootstrap def abc2(n): if n == 0 or n == 1: return 1 return abc1(n - 1) * n def main(): print(abc1(1000)) ``` ```python def abc1(n): if n == 0 or n == 1: yield 1 yield ((yield abc2(n - 1)) + n) def abc2(n): if n == 0 or n == 1: yield 1 yield ((yield abc1(n - 1)) * n) def main(): print(Bootstrap.resolve(abc1(1000))) ```