Added another example
This commit is contained in:
21
README.md
21
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)
|
||||
```
|
||||
|
13
examples/fib.py
Normal file
13
examples/fib.py
Normal file
@@ -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)
|
Reference in New Issue
Block a user