Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.4 KB

README.md

File metadata and controls

57 lines (48 loc) · 1.4 KB

A source converter made for fun based off this question on StackOverflow

Examples

Quick examples to demonstrate working of this project :

Before conversion:

def fib(n):
    if n <= 1:
        return n
    return fib(n - 1) + fib(n - 2)

print(fib(5))

After conversion:

from operator import sub, add, le

def fib(n):
    if le(n, 1):
        return n
    return add(fib(sub(n, 1)), fib(sub(n, 2)))

print(fib(5))

---

Before conversion:

def foo(x, y, z):
    z += 1
    y = x >> y
    x @= y
    x, y = y, x
    return (x + y ^ z) or y // x

After conversion:

from operator import xor, imatmul, iadd, rshift, add, floordiv

def foo(x, y, z):
    z = iadd(z, 1)
    y = rshift(x, y)
    x = imatmul(x, y)
    (x, y) = (y, x)
    return xor(add(x, y), z) or floordiv(y, x)

Features

The following conversions are implemented :

  1. Unary Operations
  2. Binary Operations
  3. Comparsion Operators
  4. Subscript Operations [❌TODO]
  5. Augmented Assignmented Operations