diff --git a/README.md b/README.md index a13c9d3..e9b14d8 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,28 @@ And you're good to go! Easy! -````python +```python import improved improved.callIMP("n := 5") # this will return a dictionary containing the key/value pair n/5 ``` + +For a less contrived example, let's calculate the nth fibonacci number +where n is user input: + +```python +import improved + +x = """ + n := read; + fib := 1; + while n > 1 do + fib := n * fib; + n := n -1 + end; + write fib +""" + +improved.callIMP(x) +``` diff --git a/examples/fib.py b/examples/fib.py new file mode 100644 index 0000000..9cfdaa3 --- /dev/null +++ b/examples/fib.py @@ -0,0 +1,13 @@ +import improved + +x = """ + n := read; + fib := 1; + while n > 1 do + fib := n * fib; + n := n -1 + end; + write fib +""" + +improved.callIMP(x)